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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

New check: d.SetId is called within Create #244

Open
jacobbednarz opened this issue Aug 31, 2021 · 0 comments
Open

New check: d.SetId is called within Create #244

jacobbednarz opened this issue Aug 31, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@jacobbednarz
Copy link

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

I just spent longer than required debugging why a test was consistently failing with the following exception for a co-worker.

    testing.go:705: Step 0 error: errors during apply:

        Error: Provider produced inconsistent result after apply

        When applying changes to cloudflare_teams_account.ocxknckonr, provider
        "cloudflare" produced an unexpected new value for was present, but now absent.

        This is a bug in the provider, which should be reported in the provider's own
        issue tracker.

The smoking gun for me here was that the state wasn't being saved and through experience I have a few ways to dig into that however my co-worker hasn't come across this before.

Eventually I found the missing d.SetId() which was the cause of why Terraform couldn't find the state to compare it to.

New or Affected Checks(s)

  • AT###

Flagged Provider Code

func resourceCloudflareTeamsAccountConfiguration() *schema.Resource {
	return &schema.Resource{
		Read: resourceExampleRead,
		Create: resourceExampleCreate,

		Schema: map[string]*schema.Schema{
			// .. snip 
		},
	}
}

func resourceExampleCreate(d *schema.ResourceData, meta interface{}) error {
	// create the resource
	return resourceExampleRead(d, meta)
}

Passing Provider Code

func resourceCloudflareTeamsAccountConfiguration() *schema.Resource {
	return &schema.Resource{
		Read: resourceExampleRead,
		Create: resourceExampleCreate,

		Schema: map[string]*schema.Schema{
			// .. snip 
		},
	}
}

func resourceExampleCreate(d *schema.ResourceData, meta interface{}) error {
	// create the resource

	d.SetId(...)

	return resourceExampleRead(d, meta)
}

References

n/a

@jacobbednarz jacobbednarz added the enhancement New feature or request label Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant