@@ -793,7 +793,7 @@ func resourceGithubRepositoryCreate(ctx context.Context, d *schema.ResourceData,
793793 }
794794 }
795795
796- err := updateVulnerabilityAlerts (d , client , ctx , owner , repoName )
796+ err := updateVulnerabilityAlerts (ctx , d , client , owner , repoName )
797797 if err != nil {
798798 return diag .FromErr (err )
799799 }
@@ -1041,7 +1041,7 @@ func resourceGithubRepositoryUpdate(ctx context.Context, d *schema.ResourceData,
10411041 }
10421042
10431043 if d .HasChange ("vulnerability_alerts" ) {
1044- err = updateVulnerabilityAlerts (d , client , ctx , owner , repoName )
1044+ err = updateVulnerabilityAlerts (ctx , d , client , owner , repoName )
10451045 if err != nil {
10461046 return diag .FromErr (err )
10471047 }
@@ -1267,7 +1267,7 @@ func resourceGithubParseFullName(resourceDataLike interface {
12671267 return parts [0 ], parts [1 ], true
12681268}
12691269
1270- func updateVulnerabilityAlerts (d * schema.ResourceData , client * github.Client , ctx context. Context , owner , repoName string ) error {
1270+ func updateVulnerabilityAlerts (ctx context. Context , d * schema.ResourceData , client * github.Client , owner , repoName string ) error {
12711271 updateVulnerabilityAlertsSDK := client .Repositories .DisableVulnerabilityAlerts
12721272 vulnerabilityAlerts , ok := d .GetOk ("vulnerability_alerts" )
12731273
@@ -1278,7 +1278,14 @@ func updateVulnerabilityAlerts(d *schema.ResourceData, client *github.Client, ct
12781278 }
12791279
12801280 resp , err := updateVulnerabilityAlertsSDK (ctx , owner , repoName )
1281- if err != nil {
1281+ if err != nil && resp != nil {
1282+ tflog .Debug (ctx , "Error updating vulnerability alerts" , map [string ]any {
1283+ "owner" : owner ,
1284+ "repository" : repoName ,
1285+ "error" : err .Error (),
1286+ "status_code" : resp .StatusCode ,
1287+ "body" : resp .Body ,
1288+ })
12821289 // Check if the error is because an Organization or Enterprise policy is preventing the change
12831290 // This is a temporary workaround while we extract Vulnerability Alerts into a separate resource.
12841291 if resp .StatusCode == http .StatusUnprocessableEntity && strings .Contains (err .Error (), "An enforced security configuration prevented modifying" ) && ! ok {
0 commit comments