Fix #4270: Emit BCP180 error for nested getSecret() instead of crashing#19258
Open
jiangmingzhe wants to merge 1 commit intoAzure:mainfrom
Open
Fix #4270: Emit BCP180 error for nested getSecret() instead of crashing#19258jiangmingzhe wants to merge 1 commit intoAzure:mainfrom
jiangmingzhe wants to merge 1 commit intoAzure:mainfrom
Conversation
…rashing
Previously, when getSecret() was used inside nested objects in module
parameters (e.g., params: { config: { secret: kv.getSecret('x') } }),
the compiler would crash with NotImplementedException during emit
instead of validating the placement during semantic analysis.
This fix adds validation logic in FunctionPlacementValidatorVisitor to
detect when getSecret() is nested inside object structures by:
- Walking up the syntax tree from the function call
- Counting ObjectSyntax nodes between the property and params boundary
- Allowing 0 levels of nesting for params, 1 for extensionConfigs
- Emitting BCP180 diagnostic for invalid nested cases
The ARM template schema only supports KeyVault references at the top
parameter level (as { reference: {...} }), not nested within value
objects, so this validation prevents generating invalid ARM templates.
Added comprehensive test coverage:
- Nested objects at various depths (2-3 levels)
- Nested objects in loops and ternary expressions
- Nested objects inside arrays
- All existing tests continue to pass (valid cases unaffected)
Fixes Azure#4270
43521bf to
1d9f672
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, when getSecret() was used inside nested objects in module parameters (e.g., params: { config: { secret: kv.getSecret('x') } }), the compiler would crash with NotImplementedException during emit instead of validating the placement during semantic analysis.
This fix adds validation logic in FunctionPlacementValidatorVisitor to detect when getSecret() is nested inside object structures by:
The ARM template schema only supports KeyVault references at the top parameter level (as { reference: {...} }), not nested within value objects, so this validation prevents generating invalid ARM templates.
Added comprehensive test coverage:
Fixes #4270
Description
Example Usage
Checklist
Microsoft Reviewers: Open in CodeFlow