Skip to content

{POSTGRESQL} az postgresql flexible sever migrate update Bug Fix: correct SDK mismatch for update migration command - #34323

Merged
Naga Nandyala (naga-nandyala) merged 3 commits into
Azure:devfrom
nasc17:nasc/dmsFix112
Nov 5, 2026
Merged

Naga Nandyala (naga-nandyala) merged 3 commits into
Azure:devfrom
nasc17:nasc/dmsFix112

Conversation

@nasc17

@nasc17 nasc17 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

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

Related command
az postgresql flexible sever migrate update

Description
--migration-name cli62db20261016onlinea --cutover --only-show-errors -o json
Actual: exit 1 at 21:34:54 IST; empty stdout; TypeError: MigrationResourceForPatch.init() got an unexpected keyword argument 'dbs_to_trigger_cutover_migration_on'. The failure occurs during local SDK model construction.

Expected: build the compatible PATCH model, submit the full cutover request, and report the service response. For end-to-end regression verification, use a new healthy small online migration that is ready for cutover; this historical migration has since been canceled. The exact traceback, environment, distinction from the service-state bug, and az rest workaround are in Description.

Discovered:
cutover passes the unsupported keyword  dbs_to_trigger_cutover_migration_on . The correct SDK keyword is  dbs_to_trigger_cutover_on . I verified it exists in SDK  3.0.0b1 , shipped with CLI 2.85.0.

Local reproduction produced the exact TypeError;  client.update  was never called. An in-memory keyword correction passed this complete payload to the mocked SDK update and returned its response unchanged:

{"properties":{"triggerCutover":"True","dbsToTriggerCutoverOn":["db1","db2"]}}

Testing Guide
Manual

History Notes
[PostgreSQL] az postgres flexible-server migration update: Fix online cutover request construction

Copilot AI balanced review requested due to automatic review settings November 2, 2026 20:08
@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.

🟡 Changes recommended

The regression test is in tests/unit, which default latest profile discovery excludes, so normal module test runs will not execute the SDK-keyword regression check.

1 open issue
What changed in this PR

This PR fixes an SDK keyword mismatch in PostgreSQL flexible-server migration cutover updates, allowing the CLI to construct the PATCH model and submit the request.

Changes:

  • Replaces the unsupported keyword with dbs_to_trigger_cutover_on.
  • Adds a regression test checking the full database cutover payload and unchanged return value.
File Description
src/​azure-cli/​azure/​cli/​command_modules/​postgresql/​tests/​unit/​test_migration_commands.py Adds a mocked regression test for cutover request construction.
src/​azure-cli/​azure/​cli/​command_modules/​postgresql/​commands/​migration_commands.py Corrects the SDK keyword used in the cutover PATCH model.

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).

@yonzhan

Copy link
Copy Markdown
Collaborator

Please fix CI issues

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

Copy link
Copy Markdown
Member

/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

nasc17 The change at postgresql/commands/migration_commands.py:148 replaces the unsupported cutover keyword and forwards the complete database list; it leaves the command's returned SDK result unchanged.

Check Status Detail
Upstream CI Passed The router snapshot reports 52/52 upstream checks completed successfully, with no…
Agent live tests Not run This is a review-only PR.
Regression coverage Unverified For postgresql: 1 focused test file(s) changed.
Findings 1 medium findings 1 medium
Risk Risk 16/100 Low Low; owner review recommended

To address

Tick each item as you address it.

  • Medium Test semantic-strength reviewer

    Details and fix

    src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_migration_commands.py:1: New scenario test has no recording in this PR: test_postgresql_migration_cutover_submits_all_databases.

    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.

    Current-head qualification: The deterministic recording warning above is a false positive for this test: line 13 derives from unittest.TestCase, not ScenarioTest; lines 16-27 mock the client and cluster validation and call the Python function directly. It has no resource preparers or recording lifecycle. Do not run this unit test live, add a cassette for it, or mark it live-only.

    Separate, confirmed scenario gap (same tool): The new test does not execute SDK HTTP serialization, service acceptance, or CLI output. Existing src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_migration.py:60-85 creates an Offline migration and only tests update without an operation; it never reaches the changed cutover branch. Its cassette is src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/recordings/test_postgres_flexible_server_migration.yaml, not an online-cutover regression recording.

    Focused remediation/verification: Retain the unit regression. Extend that existing scenario file with a healthy, cutover-ready Online migration containing two databases; have the author rerun az postgres flexible-server migration update --cutover and verify the outgoing PATCH contains both databases and the returned JSON reports the migration response. Cover rejection/error propagation as well, and commit the corresponding sanitized scenario recording for playback. This is separate integration evidence, not a recording requirement for the mock-only test. No service failure is established by this review.

Review details

Upstream CI

The router snapshot reports 52/52 upstream checks completed successfully, with no failures. This is upstream CI evidence, not an Agent test run or proof of online cutover service acceptance.

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 postgresql: 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.

No linked issue is available; the PR description supplies the scenario: construct the cutover PATCH, submit all databases, and report the service response. The author describes local reproduction and a mocked update, not a successful service cutover.

src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_migration_commands.py:15-40 uses real SDK models with a mocked client. Lines 34-39 assert the exact model dictionary, including both databases; reverting line 148 would fail model construction or that assertion. Line 40 proves return-value identity only, not CLI JSON output. No test was executed during this review. CI passed, but issue-scenario regression coverage is not verified.

Copilot feedback

Comment 4447214134 is addressed/stale: the regression now resides in postgresql/tests/latest/test_migration_commands.py:13-15. Head-pinned tools/automation/tests/__init__.py:254-255,287-295,317-320 discovers this profile path, filename and test method. No further move or thread-resolution action is needed from this review.

Risk assessment

16/100 · Low

The Low rating is driven by public CLI behavior.

  • Change scope: 2 changed files, 42 changed lines (+41 / -1), including 1 production file.
  • Affected components: postgresql
  • Risk drivers: 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 recommended for postgresql 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

@x-engineering-agent x-engineering-agent Bot added the X Engineering Agent Reviewed Agent reviewed this PR label Nov 3, 2026
@nasc17

nasc17 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Naga Nandyala (@naga-nandyala) if no blocks can we please have this merged.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@nasc17

nasc17 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Aditya Pujara (@a0x1ab) Teresa Ritorto (@teresaritorto) NoriZC corrected title. Please retrigger checks

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@nasc17

nasc17 commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

Yong Zhang (@yonzhan) Teresa Ritorto (@teresaritorto) NoriZC can we please merge this PR

@yonzhan

Copy link
Copy Markdown
Collaborator

Adding mansoor sarfraz (@msarfraz) to help review/merge

@naga-nandyala
Naga Nandyala (naga-nandyala) merged commit 50e36ef into Azure:dev Nov 5, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

8 participants