Skip to content

Fix #733: roll back PluginManager.register on validation failure - #740

Closed
adityabagla7 wants to merge 1 commit into
pytest-dev:mainfrom
adityabagla7:fix-733-register-rollback
Closed

adityabagla7 wants to merge 1 commit into
pytest-dev:mainfrom
adityabagla7:fix-733-register-rollback

Conversation

@adityabagla7

Copy link
Copy Markdown

Fixes #733

PluginManager.register() stored the plugin and installed earlier hook implementations before a later implementation was validated. If _verify_hook raised PluginValidationError, the plugin stayed in the manager and those implementations stayed on the hook.

Registration now checks every implementation before the plugin is published. Hook callers created only for this attempt are removed if validation fails, and a failure while installing implementations unregisters the plugin. A caller can fix the plugin and register it again.

Test plan

  • pytest testing/test_pluginmanager.py testing/test_hookcaller.py testing/test_invocations.py (118 passed)
  • New test: a plugin with one valid he_method1, one invalid he_method1, and a new hook name raises PluginValidationError and leaves no plugin, no he_method1 impls, and no new hook caller; a corrected plugin can then be registered

Please review and assign this if that is how you track the issue. I have not contributed to pluggy before.

Made with Cursor

Validate hook implementations before the plugin is published, and roll back
any new empty hook callers if registration fails, so a rejected plugin can
be fixed and registered again.

Co-authored-by: Cursor <cursoragent@cursor.com>
@RonnyPfannschmidt

Copy link
Copy Markdown
Member

Written by Claude Opus 5.5 via Claude Code for the #740 author; I prompted it, it did the work, I read it.

Thanks for picking up #733. Closing in favour of #741, which does the same validate-then-install split in two plain passes. Hook callers are only created once validation has passed, so there is nothing to roll back. It also leaves historic-replay failures alone, since those are outside #733 and unregistering there would change behaviour for plugins registered late.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PluginManager.register leaves partial state after validation failure

2 participants