Fix Terraform recipe failure when resource has no application property#11834
Conversation
The generateSecretSuffix function in the Kubernetes backend was
unconditionally parsing resourceRecipe.ApplicationID as a resource ID.
When ApplicationID is empty (resource has no application property),
resources.Parse("") returns "'' is not a valid resource id" error.
Fix: Skip parsing ApplicationID when it is empty, using an empty app
name in the secret suffix hash instead.
Agent-Logs-Url: https://github.com/radius-project/radius/sessions/f9f15a7d-9f56-4d7d-b58c-95c95a643c37
Co-authored-by: Reshrahim <61033581+Reshrahim@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11834 +/- ##
==========================================
+ Coverage 51.20% 51.21% +0.01%
==========================================
Files 715 715
Lines 45074 45081 +7
==========================================
+ Hits 23079 23090 +11
+ Misses 19798 19796 -2
+ Partials 2197 2195 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
When ApplicationID is empty, omit the app name component from the hash input string entirely instead of including an empty segment. Agent-Logs-Url: https://github.com/radius-project/radius/sessions/30d0a0a9-1a9e-4a6f-a7db-54d0061ac67a Co-authored-by: kachawla <74574173+kachawla@users.noreply.github.com>
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
There was a problem hiding this comment.
Pull request overview
Fixes a Terraform (Kubernetes backend) failure when a recipe resource is environment-scoped and therefore has an empty ApplicationID. The change aligns the Terraform backend behavior with existing guards in the recipe context builder/config loader by skipping ApplicationID parsing when it’s empty, and it adds a unit test to cover the scenario.
Changes:
- Guard
resources.Parse(resourceRecipe.ApplicationID)behindApplicationID != ""to avoid parsing an empty resource ID. - Exclude the application name segment from the secret-suffix hash input when no application is set (use
envName-resourceIDinstead ofenvName--resourceID). - Add a unit test validating secret suffix generation when
ApplicationIDis empty.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/recipes/terraform/config/backends/kubernetes.go | Skips parsing empty ApplicationID and adjusts hash input format accordingly. |
| pkg/recipes/terraform/config/backends/kubernetes_test.go | Adds coverage for generateSecretSuffix when ApplicationID is empty. |
Description
generateSecretSuffixin the Kubernetes backend unconditionally callsresources.Parse(resourceRecipe.ApplicationID). When a resource has noapplicationproperty (onlyenvironment),ApplicationIDis"", andresources.Parse("")returns'' is not a valid resource id.Bicep recipes already handle this correctly because the recipe context builder (
recipecontext/context.go) and config loader (configloader/environment.go) both guard onApplicationID != ""before parsing. The Terraform backend was the only callsite missing this guard.Fix: Skip parsing
ApplicationIDwhen empty, and exclude the app name component from the hash input string entirely. When an application is set, the hash input isenvName-appName-resourceID; when it is not set, the hash input isenvName-resourceID(no empty segment or double dash).Added a corresponding unit test (
Test_GenerateSecretSuffix_empty_appid).Type of change
Contributor checklist
Please verify that the PR meets the following requirements, where applicable:
eng/design-notes/in this repository, if new APIs are being introduced.