Skip to content

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

Merged
notyashhh merged 4 commits into
Azure:mainfrom
henryzdai:henrydai/fix-additional-data-parsing
May 29, 2026
Merged

[Microsoft.ChangeSafety][BugFix] fix additional data parsing issue#9901
notyashhh merged 4 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

azure-client-tools-bot-prd Bot commented May 26, 2026

⚠️Azure CLI Extensions Breaking Change Test
⚠️azure-changesafety
rule cmd_name rule_message suggest_message
⚠️ 1010 - ParaPropUpdate changesafety changerecord create cmd changesafety changerecord create update parameter additional_data: updated property aaz_type from AAZObjectArg to AAZFreeFormDictArg
⚠️ 1010 - ParaPropUpdate changesafety changerecord create cmd changesafety changerecord create update parameter additional_data: updated property type from Object to Dict<String,Any>
⚠️ 1010 - ParaPropUpdate changesafety changerecord update cmd changesafety changerecord update update parameter additional_data: updated property aaz_type from AAZObjectArg to AAZFreeFormDictArg
⚠️ 1010 - ParaPropUpdate changesafety changerecord update cmd changesafety changerecord update update parameter additional_data: updated property type from Object to Dict<String,Any>

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

Copy link
Copy Markdown
Member

@notyashhh notyashhh left a comment

Choose a reason for hiding this comment

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

Looks soild, Just a NIT, if anyone passes empty dict {}, it will silently drop so can you update these 2 instances, I can approve and merge it once done!

Comment thread src/azure-changesafety/azext_changesafety/custom.py Outdated
Comment thread src/azure-changesafety/azext_changesafety/custom.py Outdated
…ecks

Per review feedback, replace truthiness checks with explicit None checks so
that an explicitly provided empty dict {} is treated as a valid user-supplied
value rather than being silently dropped.

- _inject_additional_data_into_content: 'if not additional_data' -> 'is None'
- ChangeRecordCreate.pre_operations: 'if additional_data' -> 'is not None'
- ChangeRecordUpdate.pre_operations: same fix for consistency (duplicated pattern)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@notyashhh
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Copy Markdown
Member

@notyashhh notyashhh left a comment

Choose a reason for hiding this comment

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

Looks good!

@notyashhh notyashhh merged commit b145cb5 into Azure:main May 29, 2026
24 checks passed
@azclibot
Copy link
Copy Markdown
Collaborator

[Release] Update index.json for extension [ azure-changesafety-1.0.0b2 ] : https://dev.azure.com/msazure/One/_build/results?buildId=166044594&view=results

s-ddavydenko pushed a commit to s-ddavydenko/azure-cli-extensions that referenced this pull request May 29, 2026
…zure#9901)

* Fix --additional-data and --change-definition to accept free-form nested 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>

* Retrigger CI (transient GitHub 403 incident on prior run)

* Address PR nits: use 'is None' / 'is not None' for additional_data checks

Per review feedback, replace truthiness checks with explicit None checks so
that an explicitly provided empty dict {} is treated as a valid user-supplied
value rather than being silently dropped.

- _inject_additional_data_into_content: 'if not additional_data' -> 'is None'
- ChangeRecordCreate.pre_operations: 'if additional_data' -> 'is not None'
- ChangeRecordUpdate.pre_operations: same fix for consistency (duplicated pattern)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Henry Dai <henrydai@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

5 participants