fix: use can(index()) to handle null proxy_client_password_auth_type#85
Conversation
Terraform's contains() throws "Invalid function argument" when the value is null, even when guarded by an == null check, because both sides of || are evaluated. Replace with can(index()) which returns false for null or non-matching values without erroring. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated Terraform variable validation for Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
We may also need to adjust the version constraints on this |
Are you referencing this? There's a few hops, but looks like the issue is conflicting versions being pulled in from account-map and cloudposse/satack-config. We can test updating the latter to |
…er conflict stack-config v1.8.0 requires cloudposse/utils >= 1.7.1, < 2.0.0 while account-map pulls in stack-config v2.0.0 which requires >= 2.0.0, < 3.0.0. These constraints are mutually exclusive, causing terraform init to fail. Upgrading all four remote-state module references to v2.0.0 aligns the utils constraint to >= 2.0.0, < 3.0.0 across the full dependency tree. The remote-state module interface is identical between v1.8.0 and v2.0.0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/terratest |
1 similar comment
|
/terratest |
|
@wavemoran could you pls replace |
Replace relative path reference to account-map with a pinned GitHub source so terraform init succeeds without the CI-only account-map copy workaround. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks @wavemoran for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Thanks @wavemoran for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Thanks @wavemoran for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Thanks @wavemoran for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Thanks @wavemoran for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Thanks @wavemoran for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
Summary
contains()throwsInvalid function argumentwhen passed anullvalue, even when short-circuit evaluation with== null ||is expected — Terraform evaluates both sides of||before applying the conditioncontains(list, var)withcan(index(list, var))so null (or unset) values returnfalsecleanly without erroringproxy_client_password_auth_typeProblem
When
proxy_client_password_auth_typeis not set (defaultnull), Terraform raises:Fix
Per the Terraform
canfunction docs:canevaluates the given expression and returnstrueif it succeeds, orfalseif it returns any error — including the errorindexraises when the value is not found or is null. This is the recommended pattern for validation conditions.References
canfunction: https://developer.hashicorp.com/terraform/language/functions/can🤖 Generated with Claude Code
Summary by CodeRabbit