Skip to content

[CosmosDB] az cosmosdb: Fix computed property preservation and fleetspace validation - #34270

Open
pjohari-ms wants to merge 1 commit into
Azure:devfrom
pjohari-ms:fix/cosmosdb-fleetspace-computed-properties
Open

pjohari-ms wants to merge 1 commit into
Azure:devfrom
pjohari-ms:fix/cosmosdb-fleetspace-computed-properties

Conversation

@pjohari-ms

@pjohari-ms pjohari-ms commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

Tests Suppressions
️✔️ 130/130 ️✔️ None

Related command

  • az cosmosdb sql container update
  • az cosmosdb fleetspace create
  • az cosmosdb fleetspace update
  • az cosmosdb fleetspace account create

Description

Port the applicable maintenance fixes from Azure/azure-cli-extensions#10509 and Azure/azure-cli-extensions#10436 into the hand-written core Cosmos DB module:

  • Preserve existing computed properties when a SQL container is updated, including indexing-policy and TTL updates. Keep the existing behavior for containers with absent or empty computed properties.
  • Allow non-pooled fleetspace creation when properties.throughputPoolConfiguration is omitted, null, or {}. Continue requiring a nonblank service tier and a nonempty list of nonblank data regions on create.
  • Require positive integer throughput bounds, reject booleans, and require maximum throughput to be at least minimum throughput. Keep updates strict: both bounds are still required; partial updates and absent/null/empty update configurations remain unsupported.
  • Validate database account ARM IDs structurally, reject child resources and wrong resource types, require a nonblank location, and require the attachment name to match the database account name case-insensitively. Preserve accepted input spelling.
  • Align argument help and examples with the implemented behavior. Add real generated-SDK model assertions, public-command regressions, and a stable-API non-pooled lifecycle recording.

Compatibility: malformed inputs, inverted bounds, blank locations, and attachment aliases now fail before the write. Valid pooled request payloads and existing public flags are unchanged. This does not add partial throughput updates, pooling-disable commands, new API-kind behavior, SDK upgrades, or raw HTTP workarounds.

Source provenance: Azure/azure-cli-extensions#10509 was open when ported, using head 6a1cf6778af33139be0264e9a8b2db70be8f2fc9; Azure/azure-cli-extensions#10436 was merged, using head c88c75f1d4d9dfcde269fd2e0ba8d9cb3df05491. Extension-only SDK imports and unrelated recording refreshes were not copied.

Testing Guide

Validated commit: 4298fb33a41c75fbaa7882daa03c5ac99da298cb. Runtime: Python 3.14.7, Azure CLI/core 2.91.0, declared and installed azure-mgmt-cosmosdb==10.0.0, native default API 2026-03-15.

The existing SQL-container and pooled fleet/account scenarios first passed in playback before implementation. Only the new non-pooled fleetspace scenario needed live recording; the recording exercises create/show/delete through generated SDK operations and includes cleanup.

Run the focused tests from the repository root in the development virtual environment:

. .\env\Scripts\Activate.ps1
$env:PYTHONPATH = Join-Path (Get-Location) 'src\azure-cli'
$env:AZURE_TEST_RUN_LIVE = 'false'
azdev test CosmosdbSqlContainerUpdateTest CosmosdbFleetValidationTest CosmosdbFleetCommandTest test_cosmosdb_fleet_fleetspace_fleetspaceAccount test_cosmosdb_fleetspace_non_pooled test_cosmosdb_sql_container --profile latest --series --no-exitfirst --pytest-args '-q'

Result: 24 passed in 199.01 seconds, including the three focused playback scenarios. The equivalent direct pytest run also passed with 127 passing subtests covering numeric boundaries, omitted/null/empty values, typed request object graphs and serialization, attachment validation, inline/file input, help rendering, examples, and public update/show output.

Live recording command already executed:

$env:AZURE_TEST_RUN_LIVE = 'true'
python -m pytest src\azure-cli\azure\cli\command_modules\cosmosdb\tests\latest\test_cosmosdb_fleet_fleetspace_fleetspaceAccount_scenario.py::CosmosdbFleetScenarioTest::test_cosmosdb_fleetspace_non_pooled -q
$env:AZURE_TEST_RUN_LIVE = 'false'

Result: 1 passed in 109.51 seconds. The resulting stable-API cassette subsequently passed playback. SQL computed-property regressions use real generated SDK models with mocked operations and public commands; they were not live-recorded.

Other validation:

Command/check Result
azdev style cosmosdb Passed: pylint and flake8.
python -m compileall -q src\azure-cli\azure\cli\command_modules\cosmosdb Passed.
git diff --check 0fb575456532726e3c83aadb300957424dde8e9c HEAD Passed.
azdev linter cosmosdb Blocked locally during global command initialization by the unrelated Backup SDK package azure-mgmt-recoveryservicesbackup-passivestamp==1.0.0b1, whose installed wheel lacks its models. This is not a local full-linter pass.
Native Cosmos DB-isolated linter Passed at medium severity using azdev.operations.linter.run_linter(modules=['cosmosdb'], min_severity='medium') with normal module loading restricted to Cosmos DB and an initialized automation command context.
Pre-commit azdev scan and new recording checks Passed; the cassette contains only the scrubbed subscription ID and no common credential tokens.

Hosted CI at the time of this description update: PR title/content format, CLI linter, CLI style, license/history/doc-map, credential/secret scans, latest-index validation, and breaking-change validation passed. Additional integration, wheel, and full-test jobs were still running or queued; this description does not claim all CI or all live scenarios passed.

History Notes

[CosmosDB] az cosmosdb sql container update: Fix loss of existing computed properties during container updates
[CosmosDB] az cosmosdb fleetspace create: Support non-pooled creation with omitted, null, or empty throughput pool configuration
[CosmosDB] az cosmosdb fleetspace: Fix throughput-bound and database account attachment input validation


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

Port Azure/azure-cli-extensions#10509 and Azure/azure-cli-extensions#10436 to core using the existing Cosmos DB SDK. Preserve computed properties during SQL container updates, support non-pooled fleetspace creation, validate throughput bounds and account attachment inputs, and align help and examples. Add typed SDK and public-command regressions plus a stable non-pooled fleetspace recording.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 22:18
@azure-pipelines

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

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

Static review found the implementation and regression coverage consistent with the intended behavior, with no blocking issues; tests were not executed.

No open issues 🎉

What changed in this PR

Ports Cosmos DB fixes from the extension into core using the existing SDK, preserving computed properties during SQL container updates and improving fleetspace creation and validation.

Changes:

  • Preserve computed properties when updating SQL containers.
  • Support non-pooled fleetspace creation and validate throughput bounds and account attachment inputs.
  • Align help and examples, with typed SDK tests, public-command regressions, and a non-pooled scenario recording.
File Description
src/​azure-cli/​azure/​cli/​command_modules/​cosmosdb/​tests/​latest/​test_cosmosdb_sql_container_update.py Adds computed-property preservation regressions.
src/​azure-cli/​azure/​cli/​command_modules/​cosmosdb/​tests/​latest/​test_cosmosdb_fleet_fleetspace_fleetspaceAccount_scenario.py Adds validation, command, help, and non-pooled scenario coverage.
src/​azure-cli/​azure/​cli/​command_modules/​cosmosdb/​tests/​latest/​recordings/​test_cosmosdb_fleetspace_non_pooled.yaml Records the non-pooled fleetspace lifecycle.
src/​azure-cli/​azure/​cli/​command_modules/​cosmosdb/​custom.py Preserves computed properties and handles non-pooled creation and attachment-name checks.
src/​azure-cli/​azure/​cli/​command_modules/​cosmosdb/​_validators.py Validates creation settings, throughput bounds, and account inputs.
src/​azure-cli/​azure/​cli/​command_modules/​cosmosdb/​_params.py Wires creation-specific validation and updates argument guidance.
src/​azure-cli/​azure/​cli/​command_modules/​cosmosdb/​_help.py Documents supported behavior and updates examples.

Review effort: Balanced

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@x-engineering-agent
x-engineering-agent Bot requested a review from a team October 23, 2026 22:26
@pjohari-ms pjohari-ms changed the title [CosmosDB] Preserve computed properties and fix fleetspace validation [CosmosDB] az cosmosdb: Fix computed property preservation and fleetspace validation Oct 23, 2026
@JaysonTaiMicrosoft JaysonTaiMicrosoft added the Request X Engineering Agent Ask the agent to triage this issue or review this PR label Oct 27, 2026
@x-engineering-agent

x-engineering-agent Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

X Engineering Agent Report

Review — Comments

pjohari-ms

CI passed for reviewed head 4298fb33a41c75fbaa7882daa03c5ac99da298cb, but regression coverage of the computed-property preservation scenario is not verified. One coverage finding; no confirmed production-code defect.

Medium — 1 finding
Computed-property persistence lacks service-backed regression evidence — Tool: test-strength

At test_cosmosdb_sql_container_update.py:113–135, the update mock constructs its response from the submitted model, and show returns that same mocked response. These assertions check CLI mapping, but cannot detect the service rejecting or dropping computedProperties.

The existing src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb_commands.py:623–670 scenario creates no computed properties and checks TTL/name rather than preservation. Its tests/latest/recordings/test_cosmosdb_sql_container.yaml contains only empty computedProperties responses; its update PUT omits the field now copied by custom.py:776. The changed tests/latest/recordings/test_cosmosdb_fleetspace_non_pooled.yaml exercises fleetspace creation, not SQL container updates. These test and recording paths are under src/azure-cli/azure/cli/command_modules/cosmosdb/.

Remediation and focused validation: retain the unit tests and extend the recorded SQL scenario with two populated computed properties. Perform an indexing-policy update and a TTL update; assert both property names/queries survive each update and a subsequent independent show, while asserting the requested indexing/TTL changes. Capture the corresponding GET/PUT/GET payloads in tests/latest/recordings/test_cosmosdb_sql_container.yaml and rerun that focused scenario in playback. This requests author-provided evidence, not an Agent live-test dispatch.

Upstream CI

The supplied snapshot reports 54/54 checks completed and passed, with no failed or pending checks.

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 cosmosdb: 2 focused test file(s) and 1 recording 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.
Risk assessment — 50/100 · High

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

  • Change scope: 7 changed files, 1253 changed lines (+1214 / -39), including 4 production files.
  • Affected components: cosmosdb
  • 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 cosmosdb before merge.

Posted by x-engineering-agent (Reviewer)

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-codegen-extensibility-squad CosmosDB az cosmosdb 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.

5 participants