Skip to content

apigee: fix google_apigee_endpoint_attachment import panic#17941

Open
xuchenma wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
xuchenma:b513957540-endpointattachment-import
Open

apigee: fix google_apigee_endpoint_attachment import panic#17941
xuchenma wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
xuchenma:b513957540-endpointattachment-import

Conversation

@xuchenma

Copy link
Copy Markdown
Contributor

Summary

TestAccApigeeEndpointAttachment_apigeeEndpointAttachmentBasicTestExample fails 100% in nightly (ga and beta) with a provider panic during import:

panic: Invalid address to set: []string{"name"}
  .../helper/schema/identity_data.go:74
  .../tpgresource/import.go:72
  apigee.resourceApigeeEndpointAttachmentImport (resource_apigee_endpoint_attachment.go:420)

Root cause

The custom import called tpgresource.ParseImportId([]string{"(?P<name>.+)"}, ...) purely to load the full import id into the output-only name attribute for parsing. ParseImportId now also populates the resource identity for each captured group, so it called identity.Set("name", ...). name is not part of this resource's identity schema, so the SDK panics.

Fix

Replace the ParseImportId call with d.Set("name", d.Id()). This keeps the exact same downstream parsing of org_id / endpoint_attachment_id from name, but avoids routing a non-identity field through the identity-setting path.

(Note: ParseImportId will 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

--- PASS: TestAccApigeeEndpointAttachment_apigeeEndpointAttachmentBasicTestExample (1183.83s)

(Previously: panic on the import step.)

Fixes hashicorp/terraform-provider-google#27404

apigee: fixed a panic when importing `google_apigee_endpoint_attachment`

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>
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jun 11, 2026
@github-actions

Copy link
Copy Markdown

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.

@modular-magician modular-magician added service/apigee and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Jun 15, 2026
@modular-magician

modular-magician commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 109067f:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 1 file changed, 7 insertions(+), 3 deletions(-)
google-beta provider View Diff 1 file changed, 7 insertions(+), 3 deletions(-)

Test report

Analytics

Total Tests Passed Skipped Affected
82 40 42 0
Affected Service Packages
  • apigee

Learn how VCR tests work


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!

@github-actions

Copy link
Copy Markdown

@malhotrasagar2212 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @malhotrasagar2212 This PR has been waiting for review for 1 week. Please take a look! Use the label disable-review-reminders to disable these notifications.

@malhotrasagar2212 malhotrasagar2212 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failing test(s): TestAccApigeeEndpointAttachment_apigeeEndpointAttachmentBasicTestExample

3 participants