[Search] Fix az search service create --sku serverless failing with HTTP 400#33519
Open
mattgotteiner wants to merge 2 commits into
Open
[Search] Fix az search service create --sku serverless failing with HTTP 400#33519mattgotteiner wants to merge 2 commits into
az search service create --sku serverless failing with HTTP 400#33519mattgotteiner wants to merge 2 commits into
Conversation
… HTTP 400 The serverless SKU auto-scales and rejects `replicaCount`, `partitionCount` and `hostingMode`. These arguments default to 1/`default`, so the AAZ-generated create command always serialized them into the ARM PUT body and the service returned HTTP 400, making serverless creation impossible. Skip those properties for the serverless SKU, and fail fast with a clear error if a non-default replica/partition count or hosting mode is explicitly supplied. Other SKUs are unaffected and still send the properties. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds serverless-SKU special-casing for az search service create so replica/partition/hosting settings are omitted (and invalid non-defaults are rejected), and introduces regression/unit tests that validate the serialized ARM request body without network calls.
Changes:
- Update
SearchServiceCreate.pre_operationsto unsetreplica_count,partition_count, andhosting_modeforsku=serverless(and error on non-default values). - Add tests that build the create request body locally and assert correct serialization for serverless vs non-serverless SKUs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/search/tests/latest/test_service.py |
Adds regression/unit tests by constructing an AAZ command context and inspecting the generated request body. |
src/azure-cli/azure/cli/command_modules/search/custom.py |
Adds serverless SKU logic to prevent sending unsupported properties and to validate incompatible arguments early. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
az search service create --sku serverless failing with HTTP 400
- Use ArgumentUsageError instead of MutuallyExclusiveArgumentError for the serverless SKU checks, since the failure is an argument-not-applicable-for-SKU usage error rather than mutual exclusivity between arguments. - Construct the create operation through its normal constructor (with the HTTP client mocked) in the regression tests instead of bypassing __init__ via object.__new__, so the tests exercise the production code path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
@yonzhan can you please queue the CI build here |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related command
az search service create --sku serverlessDescription
Fixes #33514.
The serverless SKU auto-scales and rejects
replicaCount,partitionCountandhostingMode. In the spec these properties carrydefault: 1/default: ""Default""and are described as applying to the dedicated search service, so the AAZ-generatedcreatecommand defaults them and always serializes them into the ARMPUTbody. The serverless service returnsHTTP 400(The 'replicaCount' property is not applicable to the 'serverless' SKU.), making serverless creation impossible from the CLI.This change special-cases the serverless SKU in
SearchServiceCreate.pre_operations:replicaCount,partitionCountandhostingModefrom the request body for--sku serverless.MutuallyExclusiveArgumentErrorif a non-default replica/partition count or hosting mode is explicitly supplied with serverless.Why the existing test did not catch this
The only checked-in serverless test,
test_service_create_supports_serverless_sku_argument, asserts thatserverlessis a valid value of the--skuenum. It never inspected the request body. When serverless support was added the service still accepted the extra properties, so end-to-end creation worked and the body-construction problem stayed latent until the service tightened validation and began returningHTTP 400. The bug is therefore more subtle than a plain ""CLI builds the wrong body"" — client and server validation were both silent at the time.Testing
Added offline regression tests that build the actual ARM
PUTbody without network calls and assert:replicaCount/partitionCount/hostingMode,History Notes: n/a (search module has no HISTORY.rst).