Skip to content

fix: unblock CLI generator when local aaz repo misses command models or versions - #572

Open
Jian Hui (huiii99) wants to merge 1 commit into
Azure:devfrom
huiii99:fix/unblock-code-gen
Open

Jian Hui (huiii99) wants to merge 1 commit into
Azure:devfrom
huiii99:fix/unblock-code-gen

Conversation

@huiii99

@huiii99 Jian Hui (huiii99) commented Sep 15, 2026

Copy link
Copy Markdown
Member

Problem

Opening the CLI generator page for a module fails hard when the local aaz repo is out of sync with the generated code in azure-cli:

  • Miss command groups in aaz: 'az network virtual-appliance migration' blocks the page from loading at all. The only workaround is to manually delete the generated code under src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/....
  • ResponseError: Version '2025-07-01' of command 'network application-gateway address-pool create' not exist in AAZ blocks generation, even when the commands being generated are unrelated.

Both are caused by drift between azure-cli and aaz, and they block work on completely unrelated commands.
Screenshot 2026-09-15 104651

Screenshot 2026-09-15 113617

Solution

Commands and command groups that have no model in the local aaz repo no longer abort the page or the generation, they are reported instead of raising:

  • The command tree skips them, and the generate dialog shows a non-blocking warning listing what is missing and what each generate button will do to them. there, both in the command tree and in AzAtomicProfileBuilder (patch mode only).
  • Generate Edited Only (PATCH) no longer deletes anything and keeps the existing files imported by the generated __init__.py, so code with no model in aaz survives untouched.
  • Generate All (PUT) is unchanged, it still regenerates the whole aaz folder from the local aaz repo, and the dialog now warns that this deletes/downgrades the listed commands.

The aaz-dev cli generate command line path is unchanged, it still fails loudly on missing models.

Testing

  • src/aaz_dev/cli/tests/test_codegen_regressions.py: patch generation keeps files missing from aaz and accepts a removed command version.
  • src/web/src/__tests__/unit/cli/CLIModGeneratorProfileCommandTree.test.ts: missing groups are reported instead of thrown, removed versions are replaced and collected for the warning.
  • Full suites pass: pytest src/aaz_dev/cli/tests/test_codegen_regressions.py, pnpm -C src/web test (383 passed), tsc --noEmit, and pnpm lint reports no new issue in the changed files.
  • End to end against a real stale setup: network module in azure-cli against a local aaz repo that misses the network virtual-appliance migration command group and the version of 113 commands (2025-07-01, only 2022-05-01 is in aaz).
    • Before: the generator page cannot be opened, and generation fails with Version '2025-07-01' of command 'network application-gateway address-pool create' not exist in AAZ.
    • After (pnpm build:web + pnpm bundle, the served UI is a build artifact so the frontend fix needs a rebuild): the page opens without deleting any generated code, the generate dialog lists the 1 missing group and the 113 missing versions, Generate Edited Only removes 0 files and 0 folders, and the target commands are generated.

Docs

docs/pages/usage/cli_generator.md updated: the Miss command models section now describes the warning instead of the error, and Remove commands states that unpicked commands are removed by Generate All.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant