-
Notifications
You must be signed in to change notification settings - Fork 248
Fix: Add JSON escape to variables before syncing to remote pipeline #5568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add JSON escape to variables before syncing to remote Add JSON escape to variables before syncing to remote Add JSON escape to variables before syncing to remote Add JSON escape to variables before syncing to remote
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash:
pwsh:
WindowsPowerShell install
MSI install
Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide some examples of what the PR solves. I don't really understand from the current description.
@wbreza I’ve updated the PR description with a specific issue example. Please have a look! |
@vhvb1989 can you review this? |
@vhvb1989 @rajeshkamal5050 FWIW, I suspect that this happens only in Aspire use-cases when a user provides a JSON string as a parameter value. It wouldn't happen in normal azd when the parameter is marked as an I wasn't entirely sure if moving forward wwith this fix would bring about other edge cases to consider. From my quick eyes, arbitrarily assuming one way or another didn't seem like the right approach, but I haven't dug into any deeper. |
This issue also occurs in non-Aspire azd projects when user-entered parameter values contain quotes, backslashes, or special characters that require escaping. For example, if the input is This PR escapes the parameters before syncing, ensuring that the remote variable value is consistent with the local |
@Menghua1 , I don't love the idea of having each provider (gh and azdo) to manually handle the values within their implementation. I wonder if this is something that the pipeline manager can handle before calling the provider so the provider doesn't need to care. Ideally, I would love to see a change where the values are scaped right away when they are read from the environment config, with a note about it. |
Fixes issue #5507.
This PR adds a step to JSON-escape the parameters from the local
.azure/envName/config.json
before syncing them to the remote pipeline, ensuring that environment parameter values remain consistent between local and remote.Issue Example
In the local
.azure/envName/config.json
file, there is a parameter defined as a JSON string:When running
azd pipeline config
and syncing the variables in the.azure/envName/config.json
file to the remote pipeline, the value becomes unescaped:This causes azd to treat the value as an array type instead of a string in the remote pipeline, resulting in Bicep parameter parsing failures
ERROR: initializing provisioning manager: resolving bicep parameters file: error unmarshalling Bicep template parameters: invalid character 'a' after object key:value pair
.Notably, running
azd up
locally works as expected because the value is preserved as a JSON string in the.azure/envName/config.json
file.This PR ensures parameter values are JSON-escaped before syncing to the remote pipeline, keeping them consistent with the local environment.
@rajeshkamal5050 and @vhvb1989 for notification.