Skip to content

fix(compute): prevent panic in google_compute_service_attachment target_service expansion#17390

Open
raman1236 wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
raman1236:fix/service-attachment-target-service-panic
Open

fix(compute): prevent panic in google_compute_service_attachment target_service expansion#17390
raman1236 wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
raman1236:fix/service-attachment-target-service-panic

Conversation

@raman1236
Copy link
Copy Markdown

Description

The custom expand function for target_service in google_compute_service_attachment previously split the input by "/" and required at least 4 segments, returning an error for short resource names. Users referencing resources by name (e.g. google_network_services_gateway.*.name) hit confusing "invalid value for target_service" errors.

Since the DiffSuppressFunc (CompareSelfLinkOrResourceName) already handles comparing self_links with names, and the API validates the value, we can simply pass the value through.

Bug

Fixes hashicorp/terraform-provider-google#22206

File changed

mmv1/templates/terraform/custom_expand/service_attachment_target_service.go.tmpl

…et_service expansion

The custom expand function for `target_service` previously split the
input by "/" and required at least 4 segments, returning an error and
panicking for short resource names. Users referencing resources by name
(e.g. `google_network_services_gateway.*.name`) hit confusing errors.

Since the DiffSuppressFunc (`CompareSelfLinkOrResourceName`) already
handles comparing self_links with names, and the API validates the value,
we can simply pass the value through.

Fixes hashicorp/terraform-provider-google#22206
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label May 1, 2026
@github-actions github-actions Bot requested a review from hao-nan-li May 1, 2026 22:16
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@hao-nan-li, 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.

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

Labels

awaiting-approval Pull requests that need reviewer's approval to run presubmit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: runtime error: index out of range [-1]

2 participants