diff --git a/github/resource_github_actions_environment_variable.go b/github/resource_github_actions_environment_variable.go index a055c0a01c..239141e888 100644 --- a/github/resource_github_actions_environment_variable.go +++ b/github/resource_github_actions_environment_variable.go @@ -78,14 +78,11 @@ func resourceGithubActionsEnvironmentVariableCreateOrUpdate(d *schema.ResourceDa _, err := client.Actions.CreateEnvVariable(ctx, owner, repoName, escapedEnvName, variable) if err != nil { ghErr := &github.ErrorResponse{} - if errors.As(err, &ghErr) { - if ghErr.Response.StatusCode == http.StatusConflict { - // Variable already exists, try to update instead - _, err = client.Actions.UpdateEnvVariable(ctx, owner, repoName, escapedEnvName, variable) - if err != nil { - return err - } - } else { + if errors.As(err, &ghErr) && ghErr.Response.StatusCode == http.StatusConflict { + // Variable already exists, try to update instead + // If it fails here, we want to return the error otherwise continue + _, err = client.Actions.UpdateEnvVariable(ctx, owner, repoName, escapedEnvName, variable) + if err != nil { return err } } else { diff --git a/github/resource_github_user_ssh_key.go b/github/resource_github_user_ssh_key.go index 4850f60e96..34b6030fe7 100644 --- a/github/resource_github_user_ssh_key.go +++ b/github/resource_github_user_ssh_key.go @@ -97,6 +97,7 @@ func resourceGithubUserSshKeyRead(d *schema.ResourceData, meta any) error { return nil } } + return err } if err = d.Set("etag", resp.Header.Get("ETag")); err != nil {