Skip to content

Fix duplicated error message in ODataV4Format.__str__ - #49499

Draft
Ryan McGee (rjmcgee53192) wants to merge 1 commit into
Azure:mainfrom
rjmcgee53192:contrib/fix-41937
Draft

Ryan McGee (rjmcgee53192) wants to merge 1 commit into
Azure:mainfrom
rjmcgee53192:contrib/fix-41937

Conversation

@rjmcgee53192

Copy link
Copy Markdown

Fixes #41937.

Problem

ODataV4Format.__str__ rendered the error message twice:

(ResourceGroupNotFound) Resource group 'non-exist' could not be found.
Code: ResourceGroupNotFound
Message: Resource group 'non-exist' could not be found.   <-- duplicated

__str__ builds "({}) {}\n{}" from code, message, and message_details(), but message_details() also included a Message: ... line. Since HttpResponseError stores str(self.error) as its message, the duplication propagated into HttpResponseError.message too (and gets noisy fast with long messages, e.g. policy errors).

Change

Removed the redundant Message: ... line from message_details() — the message is already the leading part of __str__'s header. Output is now:

(ResourceGroupNotFound) Resource group 'non-exist' could not be found.
Code: ResourceGroupNotFound
Target: non-exist

All information is retained; nothing else in azure-core calls message_details().

Files changed

  • sdk/core/azure-core/azure/core/exceptions.py — 1-line removal in ODataV4Format.message_details()
  • sdk/core/azure-core/tests/test_exceptions.py — new regression test test_odata_v4_str_does_not_duplicate_message; updated one assertion in test_deserialized_httpresponse_error_code that encoded the old duplicated output
  • sdk/core/azure-core/CHANGELOG.md — entry under 1.42.0 (Unreleased) / Bugs Fixed

Test evidence

  • Reproduced the duplication on unmodified HEAD with a standalone script before the fix (message counted 2x in str()); after the fix it counts 1x.
  • Full tests/test_exceptions.py suite: 28 passed (includes the new regression test).
  • Note: one pre-existing test encoded the old duplicated string exactly; its assertion was updated to the corrected output — verified that test passed on clean HEAD before the change and only failed due to the intended behavior change.

)

Remove the redundant Message line from message_details(); the message is already rendered in the __str__ header. Add regression test and changelog entry.
@github-actions github-actions Bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution Ryan McGee (@rjmcgee53192)! We will review the pull request and get back to you soon.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
5 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@rjmcgee53192

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azure.core.exceptions.ODataV4Format.__str__ returns duplicated error messages

1 participant