Skip to content

fix(ms-azure): handle missing "details" field in inner-error objects - #233

Open
ashwgit wants to merge 1 commit into
release-engineering:mainfrom
ashwinifork:swith-error-details-optional
Open

ashwgit wants to merge 1 commit into
release-engineering:mainfrom
ashwinifork:swith-error-details-optional

Conversation

@ashwgit

@ashwgit ashwgit commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

@beerparty @lslebodn PTAL

Per the Azure error schema (https://schema.mp.microsoft.com/schema/error/2022-07-01) , "details" is optional.
Treat its absence as no further nesting rather than raising InvalidSchema.

Assisted-by: Claude Sonnet 4.6

Summary by Sourcery

Treat missing Azure error details as a terminal error branch while preserving validation for malformed non-list details.

Bug Fixes:

  • Handle Azure inner-error objects that omit the optional details field without raising a schema error.

Tests:

  • Add coverage for nested Azure errors without details fields.

Per the Azure error schema (https://schema.mp.microsoft.com/schema/error/2022-07-01)
, "details" is optional.
Treat its absence as no further nesting rather than raising InvalidSchema.

Assisted-by: Claude Sonnet 4.6
@sourcery-ai

sourcery-ai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Updates Azure certification-error traversal to treat an omitted optional details field as a leaf node, while continuing to reject invalid non-list details values, and adds regression coverage for the schema-compliant case.

File-Level Changes

Change Details Files
Handle optional inner-error details according to the Azure schema while preserving validation for malformed values.
  • Return no match when an error object omits details.
  • Continue raising InvalidSchema when details is present but not a list.
  • Iterate over the normalized details value during recursive certification-error detection.
cloudpub/ms_azure/utils.py
Add regression coverage for nested errors whose details field is absent.
  • Verify missing details does not raise InvalidSchema and is treated as non-certification-related.
  • Retain existing assertions for certification errors, valid non-certification errors, and empty input.
tests/ms_azure/test_utils.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="cloudpub/ms_azure/utils.py" line_range="559-561" />
<code_context>
     if code == "invalidState" and "certification" in message.lower():
         return True
-    if not isinstance(item.get('details'), list):
+    details = item.get('details')
+    if details is None:
+        return False
+    if not isinstance(details, list):
         raise InvalidSchema(f"Invalid schema for 'details' inside error object: {item}")
</code_context>
<issue_to_address>
**issue (bug_risk):** An explicitly present `"details": null` value is treated as equivalent to an omitted field and returns `False` instead of raising `InvalidSchema`, even though the Azure schema defines `details` as an optional array rather than a nullable value. This silently accepts malformed error payloads and can cause certification failures hidden behind such a payload to be classified as retryable.

**Triggers:** When Azure returns an error object containing `"details": null`.

**Suggested fix:** Check `if "details" not in item` for the omitted-field case, then retain the non-list validation so an explicit `null` remains invalid unless the schema is confirmed to allow it.

```suggestion
    if "details" not in item:
        return False
    details = item.get('details')
```
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: cloudpub/ms_azure/utils.py:561


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines +559 to +561
details = item.get('details')
if details is None:
return False

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): An explicitly present "details": null value is treated as equivalent to an omitted field and returns False instead of raising InvalidSchema, even though the Azure schema defines details as an optional array rather than a nullable value. This silently accepts malformed error payloads and can cause certification failures hidden behind such a payload to be classified as retryable.

Triggers: When Azure returns an error object containing "details": null.

Suggested fix: Check if "details" not in item for the omitted-field case, then retain the non-list validation so an explicit null remains invalid unless the schema is confirmed to allow it.

Suggested change
details = item.get('details')
if details is None:
return False
if "details" not in item:
return False
details = item.get('details')

This branch has not been deployed

No deployments
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