Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give a helpful error message when trying to import a github_branch that does not exist #734

Merged
merged 2 commits into from
Mar 24, 2021

Conversation

tibbes
Copy link
Contributor

@tibbes tibbes commented Mar 18, 2021

I noticed that in issue #636, errors are not reported properly when importing a github_branch resource. In particular, the case where the branch does not exist on GitHub is not handled by the provider and the user gets a Terraform error instead:

Error: nil entry in ImportState results. This is always a bug with
the resource that is being imported. Please report this as
a bug to Terraform.

I've updated this message to:

Error: Repository tftest does not have a branch named nosuchbranch.

- check importing a branch that exists
- check error message when importing a branch that does not exist
There was no error message if the branch the user was trying to import
did not exist on GitHub, so the user got the default terraform error:

    Error: nil entry in ImportState results. This is always a bug with
    the resource that is being imported. Please report this as
    a bug to Terraform.

The new error message is:

    Error: Repository tftest does not have a branch named nosuchbranch.
Copy link
Contributor

@jcudit jcudit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thought! Hopefully saves someone trouble down the line.

@jcudit jcudit merged commit 2cb5135 into integrations:master Mar 24, 2021
kfcampbell pushed a commit to kfcampbell/terraform-provider-github that referenced this pull request Jul 26, 2022
…at does not exist (integrations#734)

* Add tests for importing github_branch

- check importing a branch that exists
- check error message when importing a branch that does not exist

* Add error message for importing github_branch

There was no error message if the branch the user was trying to import
did not exist on GitHub, so the user got the default terraform error:

    Error: nil entry in ImportState results. This is always a bug with
    the resource that is being imported. Please report this as
    a bug to Terraform.

The new error message is:

    Error: Repository tftest does not have a branch named nosuchbranch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants