Skip to content

[Containerapp] BREAKING CHANGE: Normalize and validate Compose file inputs before deployment - #34334

Open
Greedygre (Greedygre) wants to merge 1 commit into
Azure:devfrom
Greedygre:fix/containerapp-compose-file-safety
Open

Greedygre (Greedygre) wants to merge 1 commit into
Azure:devfrom
Greedygre:fix/containerapp-compose-file-safety

Conversation

@Greedygre

@Greedygre Greedygre (Greedygre) commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ❌ Action needed

Breaking Changes Tests Suppressions
❌ 3 ️✔️ 130/130 ⚠️ 3 added
❌AzureCLI-BreakingChangeTest
❌appconfig
rule cmd_name rule_message suggest_message
❌ 1012 - SubgroupRemove appconfig enhanced-feature-flag sub group appconfig enhanced-feature-flag removed please confirm sub group appconfig enhanced-feature-flag removed
❌appservice
rule cmd_name rule_message suggest_message
❌ 1007 - ParaRemove webapp up cmd webapp up removed parameter ids please add back parameter ids for cmd webapp up
⚠️ 1003 - CmdPropAdd webapp up cmd webapp up added property deprecate_info_redirect
⚠️ 1010 - ParaPropUpdate webapp up cmd webapp up update parameter location: updated property type from string to custom_type
⚠️ 1008 - ParaPropAdd webapp up cmd webapp up update parameter name: added property id_part=name
❌monitor
rule cmd_name rule_message suggest_message
❌ 1012 - SubgroupRemove monitor account trace-container sub group monitor account trace-container removed please confirm sub group monitor account trace-container removed
❌ 1012 - SubgroupRemove monitor trace-association sub group monitor trace-association removed please confirm sub group monitor trace-association removed

Please submit your Breaking Change Pre-announcement ASAP if you haven't already. Please note:

  • Breaking changes can only be merged during the designated breaking change window
  • A pre-announcement must be released at least one month in advance

For more details on how to introduce breaking changes, refer to the documentation: azure-cli/doc/how_to_introduce_breaking_changes.md

This PR adds warning or check suppressions. Fix the underlying warning where possible and justify each remaining suppression in a code comment or the PR description.

3 added suppressions
File Line Kind Code
src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_compose_file_paths.py 254 skipped test self.skipTest('Creating symbolic links requires Windows developer mode or privilege.')
src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_compose_file_paths.py 282 skipped test @unittest.skipUnless(os.name == 'nt', 'Windows path semantics')
src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_compose_file_paths.py 290 skipped test @unittest.skipUnless(os.name == 'nt', 'Windows directory junctions')

Related command

az containerapp compose create

Description

Make local file handling consistent for Compose deployments: resolve secret files and env_file entries relative to the Compose file's directory and validate them before deployment.

Validate all services and read their local file inputs before accessing or creating a managed environment or deploying an app. Preserve the existing parser's environment-file precedence and secret mapping behavior, and surface file access and decoding failures as CLI file-operation errors.

Update command help and add regression coverage through the command handler and actual CLI dispatch. This PR changes core Azure CLI only.

Compatibility: absolute file references are no longer supported, even when they point inside the project. Relative file references are now consistently anchored to the Compose file's directory rather than the process working directory.

Testing Guide

Commands were run using the existing development virtualenv with PYTHONPATH pointing to this checkout's src\azure-cli, src\azure-cli-core, src\azure-cli-testsdk, and src\azure-cli-telemetry.

python -m pytest 'src\azure-cli\azure\cli\command_modules\containerapp\tests\latest\test_containerapp_compose_file_paths.py' -q --tb=short

Result: 19 passed, 3 skipped. The skips require Windows symbolic-link privilege. Windows junction and external-path tests passed. Real CLI dispatch tests use temporary configuration, isolate installed extensions, and block network calls.

python -m pylint --rcfile pylintrc 'src\azure-cli\azure\cli\command_modules\containerapp\_compose_utils.py' 'src\azure-cli\azure\cli\command_modules\containerapp\custom.py' 'src\azure-cli\azure\cli\command_modules\containerapp\_help.py' 'src\azure-cli\azure\cli\command_modules\containerapp\tests\latest\test_containerapp_compose_file_paths.py' --score=n

Result: passed. Repository pylint excludes tests; the new test file was also checked explicitly:

python -m pylint --rcfile pylintrc --ignore-patterns='^$' --ignore= --disable=too-many-public-methods 'src\azure-cli\azure\cli\command_modules\containerapp\tests\latest\test_containerapp_compose_file_paths.py' --score=n
git diff --cached --check

Result: both passed.

Additional verification used an offline pytest harness for all Compose scenarios, with external network calls blocked and the third-party parser's existing class-level service-order state cleared between tests: 41 passed, 3 skipped, 4 failed. All four failures were reproduced with the unmodified baseline command handler: one Log Analytics workspace-name recording mismatch and three ACR API-version recording mismatches. No recordings or unrelated product code were changed to suppress these failures.

Real Azure deployment was not run.

History Notes

[Containerapp] BREAKING CHANGE: az containerapp compose create: Require secret files and environment files to use relative paths within the Compose file's directory


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

…tory

Validate and canonicalize secret and environment file references before reading them, and load all service file inputs before cloud operations. Preserve parser behavior and add command-handler and CLI-dispatch regressions.

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

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.

🟡 Changes recommended

Path validation incorrectly converts directory access failures into InvalidArgumentValueError instead of the promised FileOperationError, bypassing the command’s read-error handling.

1 open issue
What changed in this PR

This PR updates az containerapp compose create to validate and read local file inputs before accessing Azure resources. It introduces a breaking change requiring file references to remain within the Compose file’s directory.

Changes:

  • Resolve and validate secret and environment-file paths relative to the Compose file.
  • Read file inputs before managed-environment operations and deployment, preserving existing precedence and secret mapping.
  • Document the restrictions and add command-handler and CLI-dispatch regression tests.
File Description
src/​azure-cli/​azure/​cli/​command_modules/​containerapp/​tests/​latest/​test_containerapp_compose_file_paths.py Adds path validation, file-read, and CLI-dispatch regression tests.
src/​azure-cli/​azure/​cli/​command_modules/​containerapp/​custom.py Validates and reads service files before Azure operations.
src/​azure-cli/​azure/​cli/​command_modules/​containerapp/​_help.py Documents path restrictions and environment-file behavior.
src/​azure-cli/​azure/​cli/​command_modules/​containerapp/​_compose_utils.py Adds path normalization, containment checks, and secret-reference validation.

Review effort: Balanced

Comment on lines +227 to +228
except (OSError, ValueError) as ex:
raise InvalidArgumentValueError(f"Unable to resolve the file referenced by '{field}': {ex}") from ex
@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@yonzhan
Yong Zhang (yonzhan) requested a review from a team November 3, 2026 21:59
@azure-pipelines

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

@x-engineering-agent

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

Copy link
Copy Markdown
Contributor

X Engineering Agent Pull request review: Comments

Greedygre (@Greedygre) CI is green, but the file-access error contract needs correction and the recording warning below needs disposition. Windows/runtime and deployment regression scenarios remain unverified.

Check Status Detail
Upstream CI Passed 53/53 upstream checks completed and passed; there are no CI failures.
Agent live tests Not run This is a review-only PR.
Regression coverage Unverified For containerapp: 1 focused test file(s) changed.
Findings 1 high findings 1 medium findings 1 high, 1 medium
Risk Risk 45/100 Medium Medium; owner review required

To address

Tick each item as you address it.

  • High Parent access errors bypass FileOperationError

    Details and fix

    _compose_utils.py:223–228: realpath(..., strict=True) can raise PermissionError for an untraversable parent. The broad OSError handler turns that access failure into InvalidArgumentValueError. Its caller validates at custom.py:4926, outside the subsequent read-error handler, so the new FileOperationError contract is bypassed. Copilot feedback 4452142635 is valid at this head. Validation still stops deployment; this is an error-contract defect, not evidence of file disclosure.

    Remediation: Handle PermissionError separately during path resolution and raise FileOperationError, retaining argument errors for invalid references.

    Verify: Add secret-file and env-file cases with an untraversable parent, or narrowly inject PermissionError into the strict resolution call. Assert FileOperationError and no referenced-file read, environment lookup or deployment. Retain missing/outside-path assertions for InvalidArgumentValueError.

  • Medium Test semantic-strength reviewer

    Details and fix

    src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_compose_file_paths.py:1: New scenario test has no recording in this PR: test_containerapp_compose_rejects_secret_outside_project_before_deployment, test_containerapp_compose_rejects_env_file_outside_project_before_reading, test_containerapp_compose_reports_unreadable_file_before_deployment, test_containerapp_compose_resolves_files_relative_to_compose_file, test_containerapp_compose_accepts_single_env_file.

    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.

Review details

Upstream CI

53/53 upstream checks completed and passed; there are no CI failures. This is upstream evidence, not an Agent live run. The bounded description does not establish separate author-run runtime evidence.

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 containerapp: 1 focused test file(s) changed. Scenario coverage is unverified; review the issue's required conditions, test setup, and assertions before approval. No linked issue was found in the PR timeline; inspect the source issue and its required scenario manually.

Static inspection of tests/latest/test_containerapp_compose_file_paths.py confirms meaningful local assertions: lines 127–131 check exact secret contents, environment precedence and secret references from another working directory; lines 183–189 and 230–237 require rejection before any referenced-file read or environment/deployment call; lines 340–353 check CLI error type and successful argument mapping. The single-env-file assertion at line 137 checks preserved behavior, not a new regression by itself. The unreadable-file test only denies open, not parent traversal during realpath.

These are unittest.TestCase methods with mocked deployment, not recorded ScenarioTest methods. Thus the five-name deterministic warning below is retained, but running these methods alone cannot generate recordings or prove Azure request/response behavior. No recording changed. A recording target if the relative-path case is implemented as a recorded scenario is src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/recordings/test_containerapp_compose_resolves_files_relative_to_compose_file.yaml; this is not an existing recording evidenced by this PR. Keep the local tests and resolve the warning's classification or supply a separate recorded scenario with live/playback evidence.

Focused local rerun: azdev test containerapp_compose_file_paths on supported Linux and Windows environments. Exercise both Windows-only cases at lines 282–300 and ensure symlink cases are not privilege-skipped. Add and run the parent-traversal regression described below. If a recorded scenario is added, run azdev test test_containerapp_compose_resolves_files_relative_to_compose_file --live, commit its recording, then rerun without --live. These are requested verification steps, not tests run by this Reviewer.

Risk assessment

45/100 · Medium

The Medium rating is driven by security-sensitive behavior, public CLI behavior.

  • Change scope: 4 changed files, 428 changed lines (+422 / -6), including 3 production files.
  • Affected components: containerapp
  • Risk drivers: security-sensitive behavior (+28); public CLI behavior (+18)
  • Regression evidence: Changed regression tests are included, reducing risk.
  • Confidence: High because changed-line patches were available for every production file.
  • Required review: Owning-squad review is required for containerapp before merge.

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

@naga-nandyala

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

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

@x-engineering-agent x-engineering-agent Bot added the X Engineering Agent Reviewed Agent reviewed this PR label Nov 5, 2026
@naga-nandyala

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

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

@yonzhan

Copy link
Copy Markdown
Collaborator

Adding mansoor sarfraz (@msarfraz) to help review this breaking change

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-observability-squad ContainerApp 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.

9 participants