fix(core): emit LF newlines for tsv output#33427
Conversation
|
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
|
Hi @rohan-patnaik, |
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Thank you for your contribution @rohan-patnaik! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a TSV-specific behavior to force LF (\n) newlines during output, and introduces a regression test to ensure TSV output remains consistent across platforms (notably Windows).
Changes:
- Add a regression test validating TSV output uses LF newlines even when the stream is configured for CRLF.
- Override
AzOutputProducer.out()to reconfigure the output stream newline handling when output format istsv.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/azure-cli-core/azure/cli/core/tests/test_output.py |
Adds regression test asserting TSV output is LF-terminated. |
src/azure-cli-core/azure/cli/core/_output.py |
Reconfigures output stream newline handling for TSV via out() override. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def out(self, obj, formatter=None, out_file=None): | ||
| if get_output_format(self.cli_ctx) == "tsv": | ||
| file = out_file or sys.stdout | ||
| if hasattr(file, "reconfigure"): | ||
| file.reconfigure(newline="\n") | ||
| super().out(obj, formatter=formatter, out_file=out_file) |
There was a problem hiding this comment.
Addressed in d523bf1: out() now returns super().out(...) and passes the reconfigured stream through as out_file=file.
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
Fixes #33385
Summary
This forces
tsvoutput streams to use LF newlines before writing the formatted result.Why
On Windows, Python text-mode output can translate
\ninto\r\n. That makesaz ... -o tsvunsafe in bash-style command substitution because intermediate values keep a trailing\r, which can then break follow-up CLI calls.Test plan
.venv/bin/python -m pytest src/azure-cli-core/azure/cli/core/tests/test_output.py.venv/bin/python -m compileall -q src/azure-cli-core/azure/cli/core/_output.py src/azure-cli-core/azure/cli/core/tests/test_output.pygit diff --check