Skip to content

fix s04_hooks add fault isolation to trigger_hooks#337

Open
GJZ0117 wants to merge 1 commit into
shareAI-lab:mainfrom
GJZ0117:fix/hooks-exception
Open

fix s04_hooks add fault isolation to trigger_hooks#337
GJZ0117 wants to merge 1 commit into
shareAI-lab:mainfrom
GJZ0117:fix/hooks-exception

Conversation

@GJZ0117
Copy link
Copy Markdown

@GJZ0117 GJZ0117 commented Jun 1, 2026

s04_hooks: add fault isolation to trigger_hooks

Problem:
Previously, if a hook raised an exception during execution, all subsequent hooks for that event would be skipped. This created a single point of failure where one buggy hook could bypass critical security checks (e.g., permission_hook) or monitoring hooks.

Solution:
Wrap each hook execution in try-except to isolate failures:

  • Continue executing remaining hooks even if one fails
  • Return the first blocking result (preserving original semantics)
  • Print error message with event name and failing hook function

Changes:

  • Modified trigger_hooks() in s04_hooks/code.py
  • Added exception handling around callback execution

This makes the hook system more robust while keeping the tutorial code simple and educational.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

@GJZ0117 is attempting to deploy a commit to the crazyboym's projects Team on Vercel.

A member of the Team first needs to authorize it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant