Repository navigation
Decode escaped error messages in check_success - #5364
Heath Stewart (heaths) merged 3 commits into
Conversation
|
Thank you for your contribution Amine E. (@aelmanaa)! We will review the pull request and get back to you soon. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
@microsoft-github-policy-service agree |
|
Amine E. (@aelmanaa) thanks for your contribution! I want to get a couple other opinions since I may be over-optimizing here. If the |
|
Heath Stewart (@heaths) thanks for taking this further, and for the custom deserializer; borrowing FYI to save you some digging on the red CI: the only failure is |
|
Follow-up: I confirmed this locally on your commit (1c8534e). |
|
This is fixed in another PR: #5371. Rebasing should resolve it, but hold off on any further changes until we decide to take my changes or not. At the very least we'll need the |
`ErrorDetailsInternal` borrowed `code` and `message` as `&str`, which serde_json cannot do when the JSON string contains escape sequences. Messages such as Key Vault's RBAC errors, which contain `\r\n`, then failed to parse and the error fell back to the raw response body. Use owned strings so the service message and code are extracted. Fixes Azure#5363 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
We may not need to allocate for the custom error code.
This reverts commit 1407485.
1c8534e to
a7fcc90
Compare
|
Talked to Larry Osterman (@LarryOsterman) offline who agrees this is over-optimizing. I couldn't really figure out a way to make it worth it for |
|
Heath Stewart (@heaths) thanks for merging! Two small things in the
|
|
Amine E. (@aelmanaa) thanks for noticing. I didn't realize we hadn't yet merged #5257 and am prepping that now. I'll pick up these changes there. |
Fixes issues from #5364 (comment)
Fixes #5363
check_successparses the service error body intoErrorResponseInternal, whosecodeandmessagefields were borrowed as&str. serde_json cannot borrow a string that contains JSON escape sequences, so any error message with an escape (Key Vault RBAC errors always contain\r\n) failed to parse, and the error fell back to"{status}: {raw body}"with the status text as the error code.This changes those two fields to owned
Strings. The publicErrorResponse/ErrorDetailtypes already use owned strings and parse these bodies correctly; the change only affects the error path, so the extra allocation is limited to failed requests. (#[serde(borrow)]onOption<Cow<str>>would not avoid it either, since serde does not borrow throughOption.)Tests:
deserialize_to_error_response_internal_with_escapesandmatching_against_http_error_with_escaped_messagefail onmainand pass with this change; the rest ofazure_coretests,cargo clippy --all-targets --all-features -- -D warnings, andcargo fmt --checkpass. No public API changes, so no CHANGELOG entry per the changelog instructions.This was found while building an Azure Key Vault Ethereum signer on top of
azure_security_keyvault_keys. The change was written with Claude Code; I reviewed and tested it.