Skip to content

Ensure preserve_source_parameters restores state on exception#5377

Open
yaochengchen wants to merge 2 commits intoyt-project:mainfrom
yaochengchen:bugfix_profile_decorator_safety
Open

Ensure preserve_source_parameters restores state on exception#5377
yaochengchen wants to merge 2 commits intoyt-project:mainfrom
yaochengchen:bugfix_profile_decorator_safety

Conversation

@yaochengchen
Copy link

PR Summary

This PR fixes a bug in preserve_source_parameters where source.field_parameters was not restored if the wrapped function raised an exception.

The function call is now wrapped in a try/finally block to guarantee state restoration.

A regression test has been added to ensure correct behavior.

PR Checklist

Adds a test for any bugs fixed. Adds tests for new features.

@chrishavlin chrishavlin added this to the 4.4.3 milestone Feb 13, 2026
Copy link
Contributor

@chrishavlin chrishavlin left a comment

Choose a reason for hiding this comment

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

Thanks for the thorough test here, looks good to me, but would be nice to add a comment in the code.

Co-authored-by: Chris Havlin <chris.havlin@gmail.com>
@yaochengchen
Copy link
Author

Thanks for the thorough test here, looks good to me, but would be nice to add a comment in the code.

Thanks @chrishavlin for the comment & review.

Copy link
Contributor

@chrishavlin chrishavlin left a comment

Choose a reason for hiding this comment

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

lgtm once tests pass again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments