LuciferYang opened a new pull request, #56652:
URL: https://github.com/apache/spark/pull/56652

   ### What changes were proposed in this pull request?
   `add_pipeline_analysis_context` sets `extension_id = None` up front and only 
assigns it after the extension is registered, but the `finally` block always 
calls `client.remove_user_context_extension(extension_id)`. If any step before 
that assignment fails, `extension_id` is still `None`, and 
`remove_user_context_extension(None)` runs `None.find(...)` and raises 
`AttributeError`, which hides the real failure.
   
   This change runs the cleanup only when an extension was actually registered:
   
   ```python
   finally:
       if extension_id is not None:
           client.remove_user_context_extension(extension_id)
   ```
   
   ### Why are the changes needed?
   A failure while setting up the analysis context (for example the proto 
import or `add_threadlocal_user_context_extension`) currently surfaces as 
`AttributeError: 'NoneType' object has no attribute 'find'` instead of the 
error that actually caused it.
   
   ### Does this PR introduce _any_ user-facing change?
   No. It only changes which exception is raised when setup fails: the original 
one rather than the `AttributeError` that was masking it.
   
   ### How was this patch tested?
   Added a test that makes extension registration raise and checks that the 
original error propagates and that no extension is left registered. It fails 
without the fix and passes with it.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Generated-by: Claude Code (Claude Opus 4.8)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to