Skip to content

[Microsoft.ChangeSafety][BugFix] fix additional data parsing issue#9901

Open
henryzdai wants to merge 3 commits into
Azure:mainfrom
henryzdai:henrydai/fix-additional-data-parsing
Open

[Microsoft.ChangeSafety][BugFix] fix additional data parsing issue#9901
henryzdai wants to merge 3 commits into
Azure:mainfrom
henryzdai:henrydai/fix-additional-data-parsing

Conversation

@henryzdai
Copy link
Copy Markdown
Member


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

Related command

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

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.json automatically.
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.

Henry Dai and others added 2 commits April 24, 2026 14:22
…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>
Copilot AI review requested due to automatic review settings May 26, 2026 12:43
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.0b2 and document the release notes.
  • Switch additional_data and change_definition.details to free-form dict argument/schema types in AAZ-generated commands.
  • Inject additionalData into 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
@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented May 26, 2026

ChangeSafety

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.

4 participants