docs(server): brighter webhook wiring guidance + hello_seller_with_webhooks example#553
Closed
docs(server): brighter webhook wiring guidance + hello_seller_with_webhooks example#553
Conversation
…bhooks example Closes #546 Three DX improvements making the auto_emit_completion_webhooks silent-no-op impossible to stumble into: 1. The existing boot-time AdcpError in validate_webhook_sender_for_platform() now names the three WebhookSender factory methods (from_jwk, from_bearer_token, from_standard_webhooks_secret) with copy-paste import/instantiation snippets so adopters can act on the error without opening docs. 2. hello_seller.py comment expanded to list the three constructors with one-line use-case summaries and a link to the new docs section. 3. New docs/handler-authoring.md#webhooks section: exact boot-time check conditions, all three primary sender constructors with code snippets, InMemoryWebhookDeliverySupervisor wiring, and the explicit opt-out pattern. Decision tree and Where-to-look-next updated. 4. New examples/hello_seller_with_webhooks.py demonstrates WebhookSender.from_bearer_token + InMemoryWebhookDeliverySupervisor against a fixture bearer token. 5. hello_seller_creative.py webhook comment updated to match the new three-constructor framing. https://claude.ai/code/session_01VaoqDC8iDD2tfzRFExrkK3
…tained example - Add missing key_id='wh-1' to error message snippet in validate_webhook_sender_for_platform() — omitting key_id raises TypeError on copy-paste, defeating the actionable error goal. - Rewrite examples/hello_seller_with_webhooks.py to be self-contained: inline a minimal _WebhookSeller (5 hard-required methods) instead of importing HelloSeller from examples.hello_seller, which fails when the cwd is not the repo root. https://claude.ai/code/session_01VaoqDC8iDD2tfzRFExrkK3
Contributor
Author
|
Superseded by #551 (already merged). #551 covers the same docs/handler-authoring section, expanded hello_seller, and the with_webhooks example for issue #546. Closing in favor of the merged work; if the additional changes here (hello_seller_creative.py touch-up, webhook_emit.py error message tweak) are still wanted, they can land in a separate focused PR. |
Contributor
Author
|
Acknowledged — #551 covers the core scope. If the Generated by Claude Code |
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.
Closes #546
Summary
The
auto_emit_completion_webhookssilent-no-op scenario (no sender wired, no error until a buyer actually sends a request withpush_notification_config.url) was already caught at boot byvalidate_webhook_sender_for_platform(). This PR makes the path from error to fix obvious, and gives adopters a runnable reference before they need to read the error at all.Five changes, all non-breaking:
Error message improvement (
src/adcp/decisioning/webhook_emit.py): The existingAdcpErrorraised at boot now includes copy-paste import + constructor snippets for all three primaryWebhookSenderfactory methods plusInMemoryWebhookDeliverySupervisorwiring. Previous message named the classes but not the import paths — copy-pasting it producedNameError. Also fixed a missingkey_id=in thefrom_standard_webhooks_secretsnippet (that kwarg has no default; the omission would have raisedTypeErroron copy-paste).hello_seller.pycomment expansion: Four-line comment expanded to list the three sender constructors with one-line use-case summaries and a link to the new docs section.docs/handler-authoring.md— new## Completion webhookssection: Covers the exact boot-time check conditions (only fires when advertised tools overlapSPEC_WEBHOOK_TASK_TYPES), all three primary constructors with code snippets,InMemoryWebhookDeliverySupervisorwiring, and the explicit opt-out pattern. Decision tree and "Where to look next" updated.New
examples/hello_seller_with_webhooks.py: Self-contained ~65 LOC — inlines a minimal_WebhookSeller(5 hard-required methods), wiresWebhookSender.from_bearer_token+InMemoryWebhookDeliverySupervisorwith a fixture token configurable viaWEBHOOK_BEARER_TOKENenv var. Runnable from repo root withuv run python examples/hello_seller_with_webhooks.py.hello_seller_creative.pycomment: Updated to match the new three-constructor framing.What was tested
pytest tests/ -k "webhook"— 309 passed, 27 skipped (3 pre-existing collection errors unrelated to this change)ruff check— cleanmypy src/adcp/decisioning/webhook_emit.py— cleanpython -m py_compileon all changed files — cleantest_oauth_passthrough.py,test_proposal_manager.py,test_upstream_helpers.pyconfirmed present onmainbefore this branchPre-PR review:
from_standard_webhooks_secretmissingkey_idblocker; fixed cwd-fragile cross-example import blocker by inlining minimal sellerNits noted (not fixed, not regressions):
auto_emit_completion_webhooks=Trueremoved from the serve() call in the example (it's the default; stating it added noise)Session: https://claude.ai/code/session_01VaoqDC8iDD2tfzRFExrkK3
Generated by Claude Code