apigee: fix google_apigee_endpoint_attachment import panic#17941
apigee: fix google_apigee_endpoint_attachment import panic#17941xuchenma wants to merge 1 commit into
Conversation
The custom import used tpgresource.ParseImportId with a "(?P<name>.+)" regex
solely to load the full import id into the output-only `name` attribute. Now
that ParseImportId also populates the resource identity, it called
identity.Set("name", ...) -- but `name` is not part of the endpoint
attachment's identity schema -- causing a hard panic
("Invalid address to set: name") on every import. This made
TestAccApigeeEndpointAttachment_apigeeEndpointAttachmentBasicTestExample fail
100% in nightly (ga and beta).
Set the import id directly on `name` with d.Set("name", d.Id()) instead,
preserving the existing parsing of org_id / endpoint_attachment_id while avoiding
the identity-set path.
Fixes hashicorp/terraform-provider-google#27404
BUG=513957540
Signed-off-by: Xuchen Ma <xuchenm@google.com>
|
Googlers: For automatic test runs see go/terraform-auto-test-runs. @malhotrasagar2212, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
|
Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 109067f: Diff reportYour PR generated the following diffs in downstream repositories:
Test reportAnalytics
Affected Service Packages
Step 1: Replaying Mode 🟢 All tests passed in Replaying mode! No Recording was needed. View the replaying VCR build log @xuchenma, @malhotrasagar2212 VCR tests complete for 109067f! |
|
@malhotrasagar2212 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label |
|
@GoogleCloudPlatform/terraform-team @malhotrasagar2212 This PR has been waiting for review for 1 week. Please take a look! Use the label |
malhotrasagar2212
left a comment
There was a problem hiding this comment.
LGTM, Thanks!
Summary
TestAccApigeeEndpointAttachment_apigeeEndpointAttachmentBasicTestExamplefails 100% in nightly (ga and beta) with a provider panic during import:Root cause
The custom import called
tpgresource.ParseImportId([]string{"(?P<name>.+)"}, ...)purely to load the full import id into the output-onlynameattribute for parsing.ParseImportIdnow also populates the resource identity for each captured group, so it calledidentity.Set("name", ...).nameis not part of this resource's identity schema, so the SDK panics.Fix
Replace the
ParseImportIdcall withd.Set("name", d.Id()). This keeps the exact same downstream parsing oforg_id/endpoint_attachment_idfromname, but avoids routing a non-identity field through the identity-setting path.(Note:
ParseImportIdwill panic for any resource whose custom import regex captures a field that isn't in the identity schema — a more general guard there may be worth a follow-up, but this change is scoped to the failing Apigee resource.)Test evidence
(Previously: panic on the import step.)
Fixes hashicorp/terraform-provider-google#27404