[Microsoft.ChangeSafety][BugFix] fix additional data parsing issue#9901
Open
henryzdai wants to merge 3 commits into
Open
[Microsoft.ChangeSafety][BugFix] fix additional data parsing issue#9901henryzdai wants to merge 3 commits into
henryzdai wants to merge 3 commits into
Conversation
…ted JSON The --additional-data argument was defined as AAZObjectArg with no child fields, causing 'Model AAZObjectArg has no field named safeFly' errors. The --change-definition details field had the same issue, rejecting ApiOperations payloads with 'no field named operations'. Changes: - Change additional_data from AAZObjectArg to AAZFreeFormDictArg - Change change_definition.details from AAZObjectArg to AAZFreeFormDictArg - Change corresponding AAZObjectType to AAZFreeFormDictType in builders and response schemas across create, update, show, and list - Add content injection for additionalData in custom.py (same pattern as changeDefinition) to work around AAZ builder serialization limitation - Add tests for SafeFly payload, links, and orchestration-tool arguments - Bump version to 1.0.0b2 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates the ChangeSafety CLI extension to properly accept and round-trip free-form nested JSON for --additional-data (and changeDefinition.details), including a content-injection workaround for an AAZ serialization limitation, and adds scenario tests covering SafeFly-like payloads.
Changes:
- Bump extension version to
1.0.0b2and document the release notes. - Switch
additional_dataandchange_definition.detailsto free-form dict argument/schema types in AAZ-generated commands. - Inject
additionalDatainto request payloads during Create/Update and add tests for nested JSON, links, and orchestration tool.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-changesafety/setup.py | Version bump for the next beta release. |
| src/azure-changesafety/HISTORY.rst | Release notes describing the free-form JSON fix and injection workaround. |
| src/azure-changesafety/azext_changesafety/custom.py | Implements additionalData capture + injection into request bodies for Create/Update. |
| src/azure-changesafety/azext_changesafety/tests/latest/test_changesafety.py | Extends mocks and adds tests for --additional-data, --links, --orchestration-tool. |
| src/azure-changesafety/azext_changesafety/aaz/latest/changesafety/changerecord/_create.py | Uses free-form dict arg/type for additional_data and changeDefinition.details. |
| src/azure-changesafety/azext_changesafety/aaz/latest/changesafety/changerecord/_update.py | Uses free-form dict arg/type for additional_data and changeDefinition.details. |
| src/azure-changesafety/azext_changesafety/aaz/latest/changesafety/changerecord/_show.py | Reads additionalData and changeDefinition.details as free-form dict types. |
| src/azure-changesafety/azext_changesafety/aaz/latest/changesafety/changerecord/_list.py | Reads additionalData and changeDefinition.details as free-form dict types. |
| return content | ||
|
|
||
| additional_data = additional_data_value.to_serialized_data() | ||
| if not additional_data: |
Comment on lines
+387
to
+392
| if additional_data: | ||
| self.ctx.set_var( | ||
| 'additional_data', | ||
| additional_data, | ||
| schema_builder=_build_any_type, | ||
| ) |
Comment on lines
+381
to
+392
| # Capture additional_data for injection into request content. | ||
| # The AAZ builder cannot serialize AAZFreeFormDictType, so we | ||
| # store the raw value and inject it via the content property. | ||
| additional_data_arg = getattr(self.ctx.args, "additional_data", None) | ||
| if has_value(additional_data_arg): | ||
| additional_data = additional_data_arg.to_serialized_data() | ||
| if additional_data: | ||
| self.ctx.set_var( | ||
| 'additional_data', | ||
| additional_data, | ||
| schema_builder=_build_any_type, | ||
| ) |
Comment on lines
623
to
+632
| class ChangeRecordsCreateOrUpdateAtSubscriptionLevel( | ||
| _ChangeRecordUpdate.ChangeRecordsCreateOrUpdateAtSubscriptionLevel): | ||
| """Override PUT at subscription level to preserve original changeDefinition.""" | ||
| """Override PUT at subscription level to preserve changeDefinition and inject additionalData.""" | ||
|
|
||
| @property | ||
| def content(self): | ||
| content = super().content | ||
| # Preserve original changeDefinition - it cannot be updated | ||
| return _preserve_change_definition_in_content(content, self.ctx) | ||
| content = _preserve_change_definition_in_content(content, self.ctx) | ||
| content = _inject_additional_data_into_content(content, self.ctx) | ||
| return content |
Collaborator
|
ChangeSafety |
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.
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install wheel==0.30.0required)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.