@@ -686,7 +686,7 @@ func resourceGithubRepositoryCreate(ctx context.Context, d *schema.ResourceData,
686686 return diag .FromErr (err )
687687 }
688688
689- d .SetId (* repo .Name )
689+ d .SetId (repo .GetName () )
690690 }
691691 } else if d .Get ("fork" ).(string ) == "true" {
692692 // Handle repository forking
@@ -758,6 +758,7 @@ func resourceGithubRepositoryCreate(ctx context.Context, d *schema.ResourceData,
758758 }
759759
760760 archived := d .Get ("archived" ).(bool )
761+ // If the repository is archived on creation, we need to skip calling Update to avoid 403 errors
761762 if archived {
762763 tflog .Debug (ctx , "Repository archived, skipping modifying topics, pages, visibility, and vulnerability alerts" , map [string ]any {
763764 "owner" : meta .(* Owner ).name ,
@@ -939,6 +940,13 @@ func resourceGithubRepositoryUpdate(ctx context.Context, d *schema.ResourceData,
939940 return nil
940941 }
941942
943+ tflog .Debug (ctx , "Updating repository" , map [string ]any {
944+ "owner" : meta .(* Owner ).name ,
945+ "repository" : d .Id (),
946+ "archived" : d .Get ("archived" ).(bool ),
947+ "archived_change" : d .HasChange ("archived" ),
948+ })
949+
942950 client := meta .(* Owner ).v3client
943951
944952 repoReq := resourceGithubRepositoryObject (d )
@@ -988,7 +996,7 @@ func resourceGithubRepositoryUpdate(ctx context.Context, d *schema.ResourceData,
988996 if err != nil {
989997 return diag .FromErr (err )
990998 }
991- d .SetId (* repo .Name )
999+ d .SetId (repo .GetName () )
9921000
9931001 if d .HasChange ("pages" ) && ! d .IsNewResource () {
9941002 opts := expandPagesUpdate (d .Get ("pages" ).([]any ))
@@ -1016,15 +1024,15 @@ func resourceGithubRepositoryUpdate(ctx context.Context, d *schema.ResourceData,
10161024
10171025 if d .HasChange ("topics" ) {
10181026 topics := repoReq .Topics
1019- _ , _ , err = client .Repositories .ReplaceAllTopics (ctx , owner , * repo .Name , topics )
1027+ _ , _ , err = client .Repositories .ReplaceAllTopics (ctx , owner , repo .GetName () , topics )
10201028 if err != nil {
10211029 return diag .FromErr (err )
10221030 }
1023- d .SetId (* repo .Name )
1031+ d .SetId (repo .GetName () )
10241032
10251033 if d .HasChange ("topics" ) {
10261034 topics := repoReq .Topics
1027- _ , _ , err = client .Repositories .ReplaceAllTopics (ctx , owner , * repo .Name , topics )
1035+ _ , _ , err = client .Repositories .ReplaceAllTopics (ctx , owner , repo .GetName () , topics )
10281036 if err != nil {
10291037 return diag .FromErr (err )
10301038 }
@@ -1136,7 +1144,7 @@ func expandPagesUpdate(input []any) *github.PagesUpdate {
11361144 // must include the branch name and optionally the subdirectory /docs.
11371145 // e.g. "master" or "master /docs"
11381146 // This is only necessary if the BuildType is "legacy".
1139- if update .BuildType == nil || * update .BuildType == "legacy" {
1147+ if update .BuildType == nil || update .GetBuildType () == "legacy" {
11401148 pagesSource := pages ["source" ].([]any )[0 ].(map [string ]any )
11411149 sourceBranch := pagesSource ["branch" ].(string )
11421150 sourcePath := ""
0 commit comments