Skip to content

fix: compute recipe context before terraform get to satisfy required argument validation#11792

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-missing-required-argument
Draft

fix: compute recipe context before terraform get to satisfy required argument validation#11792
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-missing-required-argument

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

Description

Terraform 1.14.9 validates required module arguments during terraform get. The upstream terraform-private-modules//kubernetes-redis module requires a context variable, but the Terraform driver was only injecting it AFTER the download step — causing terraform get to fail with Missing required argument: context.

Fix: Compute and include the recipe context in the module config before terraform get. After download and inspection, remove it if the module doesn't actually declare the variable (to avoid "unexpected argument" errors during init/apply).

  • pkg/recipes/terraform/execute.go — Reorder generateConfig and GetRecipeMetadata to add context before save/download. After inspection, call RemoveRecipeContext if module lacks the variable.
  • pkg/recipes/terraform/config/config.go — Add RemoveRecipeContext(moduleName) method.
  • pkg/recipes/terraform/execute_test.go — Update Test_GetTerraformConfig_InvalidDirectory since getTerraformConfig no longer saves to disk.
  • pkg/recipes/terraform/config/config_test.go — Add Test_RemoveRecipeContext.

Type of change

  • This pull request fixes a bug in Radius and has an approved issue (issue link required).

Contributor checklist

Please verify that the PR meets the following requirements, where applicable:

  • An overview of proposed schema changes is included in a linked GitHub issue.
    • Yes
    • Not applicable
  • A design document PR is created in the design-notes repository, if new APIs are being introduced.
    • Yes
    • Not applicable
  • The design document has been reviewed and approved by Radius maintainers/approvers.
    • Yes
    • Not applicable
  • A PR for the samples repository is created, if existing samples are affected by the changes in this PR.
    • Yes
    • Not applicable
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
    • Yes
    • Not applicable
  • A PR for the recipes repository is created, if existing recipes are affected by the changes in this PR.
    • Yes
    • Not applicable

…argument validation

Terraform 1.14.9 validates required module arguments during `terraform get`.
The upstream kubernetes-redis module requires a `context` argument, but it was
only being added AFTER the download step. This moves the recipe context
computation to BEFORE the download, ensuring required arguments are present
when terraform validates during module download.

After download and inspection, if the module does not declare a context
variable, it is removed from the config to avoid 'unexpected argument' errors
during init/apply.

Agent-Logs-Url: https://github.com/radius-project/radius/sessions/da1fcb4d-e5e9-4735-822f-cc86911c2544

Co-authored-by: sylvainsf <540991+sylvainsf@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing required argument in Test_TerraformPrivateGitModule_KubernetesRedis fix: compute recipe context before terraform get to satisfy required argument validation Apr 30, 2026
Copilot AI requested a review from sylvainsf April 30, 2026 18:25
@github-actions
Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@radius-functional-tests
Copy link
Copy Markdown

radius-functional-tests Bot commented Apr 30, 2026

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository radius-project/radius
Commit ref 60b5a50
Unique ID funcd4b645bc41
Image tag pr-funcd4b645bc41
  • gotestsum 1.13.0
  • KinD: v0.29.0
  • Dapr: 1.14.4
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funcd4b645bc41
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funcd4b645bc41
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-funcd4b645bc41
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funcd4b645bc41
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funcd4b645bc41
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
❌ Test tool installation for ucp-cloud failed. Please check the logs for more details
❌ Failed to install Radius for ucp-cloud functional test. Please check the logs for more details
❌ ucp-cloud functional test failed. Please check the logs for more details
❌ corerp-cloud functional test cancelled. Please check the logs for more details

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 12.50000% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.39%. Comparing base (ec789e8) to head (60b5a50).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/recipes/terraform/execute.go 0.00% 21 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11792      +/-   ##
==========================================
- Coverage   51.40%   51.39%   -0.02%     
==========================================
  Files         699      699              
  Lines       44036    44048      +12     
==========================================
- Hits        22638    22637       -1     
- Misses      19244    19256      +12     
- Partials     2154     2155       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

Unit Tests

    2 files  ±0    415 suites  ±0   6m 46s ⏱️ -5s
4 867 tests +1  4 865 ✅ +1  2 💤 ±0  0 ❌ ±0 
5 770 runs  +1  5 768 ✅ +1  2 💤 ±0  0 ❌ ±0 

Results for commit 60b5a50. ± Comparison against base commit ec789e8.

delete(mod, recipecontext.RecipeContextParamKey)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if users were using the context to pass some information? I am a bit doubtful if this could break their recipe. But we were also talking about the context being not important since we now pass the connected resource's properties. We just have not documented the change / made sure our recipes dont still use context + @kachawla for inputs.

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.

Test_TerraformPrivateGitModule_KubernetesRedis failing on main: 'Missing required argument: context'

3 participants