Repository navigation
feat(hook): honor before_processing return value to gate chain execution - #172
Merged
Merged
Conversation
before_processing now follows the same continue/halt contract as chain links: a truthy return (vcon_id) means continue, a falsy return means skip the chain for this vCon without raising and without sending it to the DLQ. The default hook returns vcon_id so existing behaviour is preserved. The worker logs the skip and after_processing still runs. This gives hooks a graceful "defer" signal so they can manage their own retry/back-off state without forcing the worker to DLQ the vCon. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Make
hook.before_processinghonor its return value the same way chain links do:None/False/""→ skip the chain for this vCon. No exception, no DLQ push.after_processingstill runs infinally.The default hook is updated to explicitly
return vcon_idso the default behaviour is preserved.Motivation
Today the only way a hook can stop chain processing is to raise an exception, which the worker treats as a chain failure and pushes to the DLQ. That's the right behaviour for unexpected errors, but it conflates "the hook wants to defer this vCon" with "chain processing failed". Hooks that legitimately want to skip a vCon (for example, to defer it to a custom retry queue) had no way to do so without unwanted DLQ side effects.
This mirrors the existing chain-link
should_continue_chainpattern (module.runreturns the vcon_id to continue, falsy to halt) — so the contract is consistent for links and hooks.Breaking change
Hooks that previously relied on the implicit
Nonereturn will now skip the chain instead of continuing. Custombefore_processingimplementations must explicitlyreturn vcon_idfor normal continuation. The bundled default hook is updated accordingly.Recommended release tag
v2.0.0(MAJOR bump fromv1.0.2, per SemVer for a breaking contract change).Suggested annotated-tag message:
Test plan
docker exec ... pytest)process()is not called, no DLQ entry,after_processingstill invoked witherror=None🤖 Generated with Claude Code