Skip to content

Conversation

Copy link

Copilot AI commented Dec 8, 2025

When syncing environment variables to remote pipelines (GitHub Actions/Azure DevOps), values containing JSON-like content (e.g., ["api://guid"]) were being incorrectly parsed as JSON arrays instead of strings, causing Bicep parameter failures.

Changes

cli/azd/pkg/pipeline/pipeline.go:

  • Added escapeValuesForPipeline() to apply JSON escaping using json.Marshal(), stripping outer quotes
  • Modified mergeProjectVariablesAndSecrets() to escape both variables and secrets before returning
  • Moves escaping logic from individual providers (GitHub/AzDo) to centralized pipeline manager per reviewer feedback

cli/azd/pkg/pipeline/pipeline_escape_test.go:

  • Added test coverage for JSON-like strings, simple values, and edge cases

Example

Before:

// In .azure/envName/config.json
{"ValidAudiences": "[\"api://guid\"]"}

// Sent to pipeline (incorrectly parsed as array)
["api://guid"]

After:

// In .azure/envName/config.json  
{"ValidAudiences": "[\"api://guid\"]"}

// Sent to pipeline (correctly escaped as string)
[\"api://guid\"]

The escaping uses standard JSON marshaling to handle all special characters (quotes, backslashes, brackets), ensuring pipeline providers treat values as strings regardless of content.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Implement centralized value escaping in mergeProjectVariablesAndSecrets
to prevent JSON-like values from being incorrectly parsed by pipeline
providers. This addresses the issue where values like `["api://..."]`
need to be escaped to `[\"api://...\"]` before being sent to GitHub
Actions or Azure DevOps.

Following reviewer feedback to handle escaping at the pipeline manager
level rather than in each provider implementation.

Co-authored-by: Menghua1 <[email protected]>
Copilot AI changed the title [WIP] Refactor handling of config values in Azure provider Centralize JSON escaping for pipeline variables at manager level Dec 8, 2025
Copilot AI requested a review from Menghua1 December 8, 2025 08:30
Repository owner deleted a comment from Copilot AI Dec 9, 2025
Repository owner deleted a comment from Copilot AI Dec 9, 2025
Repository owner deleted a comment from Copilot AI Dec 9, 2025
@Menghua1 Menghua1 closed this Dec 9, 2025
@Menghua1 Menghua1 deleted the copilot/fix-azure-config-value-handling branch December 9, 2025 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants