Skip to content

[Batch] az batch: Allow = in values of key=value arguments such as --environment-settings and --metadata - #34321

Merged
xuming-ms merged 2 commits into
Azure:devfrom
mskeyansong:keyan/batch-fix-equals-in-values
Nov 15, 2026
Merged

xuming-ms merged 2 commits into
Azure:devfrom
mskeyansong:keyan/batch-fix-equals-in-values

Conversation

@mskeyansong

@mskeyansong Keyan Song (mskeyansong) commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ️✔️ All clear

Breaking Changes Tests Suppressions
️✔️ None ️✔️ 130/130 ️✔️ None

Related command
az batch task create, az batch pool create, az batch pool reset, az batch job create,
az batch job-schedule create (every argument that takes key=value pairs)

Description
Fixes #24887.

Values of key=value arguments were split on every =, so any value that contains = was rejected with
"Incorrectly formatted environment settings" (or the metadata equivalent). Common values hit this: connection strings
(CONN=Server=tcp:x;Database=y) and base64 text that ends in =.

The three parsers (metadata_item_format, string_dictionary_format, environment_setting_format) now split on the
first = only, the same way resource_file_format already does. Input without any = is still rejected.

Testing Guide

  • Updated unit tests: test_batch_metadata_item_format, test_batch_environment_setting_format; new
    test_batch_string_dictionary_format.
  • azdev test batch (61 passed, playback), azdev style batch, azdev linter batch.
  • Example: az batch task create --job-id job1 --task-id task1 --command-line "cmd /c set" --environment-settings "CONN=Server=tcp:x;Database=y"
    now sends {"name": "CONN", "value": "Server=tcp:x;Database=y"} instead of failing.

History Notes
[Batch] az batch task create: Allow = in --environment-settings values
[Batch] az batch pool create: Allow = in --metadata and --start-task-environment-settings values


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI balanced review requested due to automatic review settings November 2, 2026 19:43
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Nov 2, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution Keyan Song (@mskeyansong)! We will review the pull request and get back to you soon.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

Copilot AI left a comment

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.

🟢 Approval recommended

No active review issues remain for the Azure Batch parser change to preserve embedded equals signs in argument values.

No open issues 🎉

What changed in this PR

Fixes #24887 by allowing embedded = characters in Azure Batch key=value argument values, including connection strings and padded base64 tokens.

Changes:

  • Updates metadata, dictionary, and environment-setting parsers to split only on the first =, while still rejecting input without a separator.
  • Adds regression coverage for embedded equals signs and malformed dictionary input.
File Description
src/​azure-cli/​azure/​cli/​command_modules/​batch/​tests/​latest/​test_batch_commands.py Updates parser tests and adds dictionary-format coverage.
src/​azure-cli/​azure/​cli/​command_modules/​batch/​_validators.py Preserves equals signs within values in all three parsers.

Review effort: Balanced

@mskeyansong

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Microsoft"

@yonzhan

Copy link
Copy Markdown
Collaborator

Please fix CI issues

@yonzhan
Yong Zhang (yonzhan) requested a review from a team November 2, 2026 22:16
@mskeyansong

Copy link
Copy Markdown
Contributor Author

Yong Zhang (@yonzhan) thanks! The only failures were the Windows MSI/ZIP build jobs. They stopped in the build script's pip step (ERROR: To modify pip, please run the following command), the same on the other open PRs at the time, and #34328 fixed that. Could you re-run the pipelines here? All other checks pass.

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

Values for `--environment-settings`, `--metadata`, and other `key=value`
arguments were split on every `=`, so values such as connection strings or
base64 text were rejected. Split on the first `=` only, as resource files
already do.

Fixes Azure#24887

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mskeyansong
Keyan Song (mskeyansong) force-pushed the keyan/batch-fix-equals-in-values branch from 1d70941 to 5b5f87b Compare November 3, 2026 03:49
@mskeyansong

Copy link
Copy Markdown
Contributor Author

Yong Zhang (@yonzhan) thanks for the re-run! The Windows jobs still failed because the PR's merge commit was built on an older dev without #34328. I rebased on the latest dev, could you run the pipelines once more?

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@naga-nandyala Naga Nandyala (naga-nandyala) added the Request X Engineering Agent Ask the agent to triage this issue or review this PR label Nov 3, 2026
@x-engineering-agent

x-engineering-agent Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

X Engineering Agent Pull request review: Comments

Keyan Song (@mskeyansong) Static inspection of head 048d5a8fd6a86c9e89350c1e2768eea24c0aa693 found no production defect. The retained automated recording warning below appears to misclassify unit tests; reconcile it with the tool owner rather than change Batch source or dispatch live tests.

Check Status Detail
Upstream CI Failed The supplied snapshot reports 52 completed checks, 52 passed, and no failures.
Agent live tests Not run This is a review-only PR.
Regression coverage Unverified For batch: 1 focused test file(s) changed.
Findings 1 medium findings 1 medium
Risk Risk 0/100 Low Low

To address

Tick each item as you address it.

  • Medium Test semantic-strength reviewer

    Details and fix

    src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_commands.py:6: New scenario test has no recording in this PR: test_batch_string_dictionary_format, test_batch_task_create_environment_settings.

    Remediation: Run the test live and commit its recording, or mark it live only when it cannot be replayed.

    Verify: Confirm the test passes in playback mode from the committed recording.

    Inspection qualification: This is retained automated evidence, not a confirmed semantic defect. Both tests inherit unittest.TestCase (lines 31 and 674), not a recorded scenario class. The dictionary test directly calls the parser; the command test mocks both BatchClient.create_task and get_task (680–681). Neither requires a recording or a live-only marker. Escalate this classification to the review-tool owner; no Batch source change is justified by it.

Review details

Upstream CI

The supplied snapshot reports 52 completed checks, 52 passed, and no failures. Failure relevance counts: 0 PR-related, 0 unrelated, 0 uncertain/unverified. The author reports 61 Batch tests passed in playback plus style/linter validation; this review did not independently execute those commands.

Test validation

  • Agent live test: Not run; this is a review-only PR. Check author-provided test evidence and upstream CI separately.
  • Regression coverage: For batch: 1 focused test file(s) changed. Scenario coverage is unverified; review the issue's required conditions, test setup, and assertions before approval. Changed tests invoke az batch task create, but invocation alone does not verify the required scenario or output. No linked issue was found in the PR timeline; inspect the source issue and its required scenario manually.

Static evidence supplement: The separately supplied context bundle does contain issue #24887. Its quoted SQL connection-string case reaches _params.py:433 → _validators.py:87 → custom.py:544–558. Splitting only at the first = preserves the complete value. In src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_commands.py, assertions at 59, 69, 72 and 76 cover the three changed parsers, repeated equals and base64 padding. Reverting each corresponding parser change raises before its equality assertion. Lines 695–703 additionally assert successful CLI parsing, job ID and the complete SDK request dictionary, including spaces, semicolons, multiple equals and a second setting. Lines 710–711 assert malformed input exits with code 2 before any create request.

End-to-end issue-scenario regression coverage not verified: the Batch service response and displayed CLI environment values are not exercised. The mocked response contains only id, and stdout is discarded. The outgoing environmentSettings[].value is asserted intact at the SDK boundary; no response schema, output formatter or API version changes. There are no changed recordings, and no recording path applies to these two unit tests. This limitation is not evidence of a production bug or a requirement to add live tests for deterministic parsing.

For focused maintainer verification, rerun azdev test test_batch_metadata_item_format test_batch_environment_setting_format test_batch_string_dictionary_format test_batch_task_create_environment_settings from the test file above. Reconcile the automated scenario classification before requesting recording work.

Risk assessment

0/100 · Low

The Low rating reflects the detected change scope with no elevated security, reliability, customer, operational, dependency, sovereign-cloud, generated-output, or cross-component signal.

  • Change scope: 2 changed files, 68 changed lines (+62 / -6), including 1 production file.
  • Affected components: batch
  • Risk drivers: No elevated risk signal was detected.
  • Regression evidence: Changed regression tests are included, reducing risk.
  • Confidence: High because changed-line patches were available for every production file.
  • Required review: No additional owning-squad review signal was detected.

Ask the Agent

Tick a box to queue an action. Requires write access to this repository.

  • Re-review this PR
  • Run Agent live tests on this PR

X Engineering Agent · Reviewer · React with +1 or -1 to train the agent

@x-engineering-agent x-engineering-agent Bot added the X Engineering Agent Reviewed Agent reviewed this PR label Nov 3, 2026
Runs the command through the CLI's argument parsing with the Batch client's
`create_task` and `get_task` mocked. A quoted SQL connection string (spaces
and several `=`) and a second variable reach the task request with their
exact names and values; a setting without `=` is still rejected and nothing
is sent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mskeyansong

Copy link
Copy Markdown
Contributor Author

I added a test in 048d5a8 that runs az batch task create through command parsing with the Batch SDK calls mocked, using a quoted SQL connection string with spaces and multiple = plus another environment variable. It asserts the exact names and values in the task request, and that malformed input (no =) is still rejected before any request is sent.

Re-recording test_batch_task_create_cmd live needs a Batch test account, which I don't have yet. Yong Zhang (@yonzhan) could you run the pipelines again?

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@mskeyansong

Copy link
Copy Markdown
Contributor Author

Hi JaysonTaiMicrosoft Teresa Ritorto (@teresaritorto), could you take a look? It fixes #24887, checks are green, and I'd like it in the December release. Thanks! ADO: https://msazure.visualstudio.com/AzureBatch/_workitems/edit/40378640

@xuming-ms
xuming-ms merged commit 29fe8c7 into Azure:dev Nov 15, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-observability-squad Batch az batch customer-reported Issues that are reported by GitHub users external to the Azure organization. Request X Engineering Agent Ask the agent to triage this issue or review this PR X Engineering Agent Reviewed Agent reviewed this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to set environment setting for Batch task when there are equal signs in the value such as a Sql Connection string

8 participants