fix(salesforce-api): #3939 preserve native MDAPI exception types in BaseMetadataApiCall#3984
Draft
jstvz wants to merge 2 commits into
Draft
fix(salesforce-api): #3939 preserve native MDAPI exception types in BaseMetadataApiCall#3984jstvz wants to merge 2 commits into
jstvz wants to merge 2 commits into
Conversation
…ons propagate untouched Adds TestCallExceptionPropagation covering BaseMetadataApiCall.__call__ exception handling. Three tests demonstrate that ApexTestException, MetadataApiError, and MetadataComponentFailure raised inside _process_response are currently masked by MetadataParseError; a fourth test pins the safety-net behavior that genuinely unexpected exceptions (e.g. KeyError from XML parsing) should still be wrapped. These tests fail on unmodified source; the fix follows in the next commit.
…iCall to preserve native exception types
`BaseMetadataApiCall.__call__` previously wrapped EVERY exception
raised inside `_process_response` as
`MetadataParseError("Could not process MDAPI response: ...")`. This
masked CumulusCI's own legitimate failure exceptions:
`MetadataApiError`, `MetadataComponentFailure` (subclass of
`MetadataApiError`), and `ApexTestException`: all of which
`_process_response` raises intentionally on real deploy/test failures.
Users running deploy tasks saw messages like
"Could not process MDAPI response: Apex Test Failure: ..."
instead of the underlying `ApexTestException`, breaking exception-type
based handling downstream and adding noisy prefix to error reports.
Narrow the except clause: native CumulusCI exception types
re-raise untouched; only genuinely unexpected exceptions (e.g.
KeyError/ValueError from malformed XML parsing) are still wrapped as
`MetadataParseError`, preserving the safety net. The new wrap uses
`raise ... from e` to preserve the cause chain for diagnostics.
Catching `MetadataApiError` covers `MetadataComponentFailure` and
`MetadataParseError` (both subclasses); `ApexTestException` is caught
explicitly because it inherits from `CumulusCIFailure`, not from
`MetadataApiError`.
Regression test added in the previous commit. Full
`cumulusci/salesforce_api/` suite passes (296 tests, zero new
failures).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3939.
BaseMetadataApiCall.__call__wrapped all exceptions in a genericexcept Exceptionclause, includingMetadataApiErrorandApexTestException, hiding the structured detail that downstream code relies on (component failures, test failure summaries, etc.).The fix narrows the except clause:
MetadataApiErrorandApexTestExceptionpropagate untouched, while truly unexpected errors are still wrapped as before.Test plan
cumulusci/salesforce_api/tests/test_metadata.py::TestCallExceptionPropagation4 tests pass (new).cumulusci/tests/triage/test_issue_3939.pyremoved in the GREEN commit; test now passes.uv run pytest cumulusci/salesforce_api/tests/test_metadata.py -qclean.Provenance
Reproduced and characterized in the v5 triage evidence pack (PR #3979). See
docs/triage/v5/repro-results.md(### #3939) for the full narrative.Companion to #3938 (same author, same day, same task family; REST-side raise-on-failure).