feat(hubspot): DB-free webhook receiver via 2-hop resolve#92
Merged
Conversation
Aligns the webhooks extension with frigg's new useDatabase flag + route namespacing (friggframework/frigg#596). The receiver no longer touches the database; the portal→integration lookup moves to the queue worker. - index.js: declare `useDatabase: false`; add the HUBSPOT_WEBHOOK_RESOLVE queue event. - handlers.js: - onHubSpotWebhookReceived (route, DB-free): verify v3 signature, then enqueue one HUBSPOT_WEBHOOK_RESOLVE per event carrying the raw payload. No portal lookup, no DB access. - onHubSpotWebhookResolve (worker, DB): reverse-look up portalId → integrationId on a dry instance, then re-enqueue HUBSPOT_WEBHOOK bound to that integration so the worker hydrates it and runs the consumer's handler with the correct per-account context. Uses the framework's documented dry-instance path; ambiguous resolution propagates. - onHubSpotWebhook: unchanged no-op default (consumer overrides). - README: document the DB-free 2-hop flow + namespaced URL (/{bindingKey}/webhooks). 37 unit tests: receiver asserts NO db lookup + enqueues RESOLVE; resolve handler asserts lookup + re-enqueue / skip / ambiguity propagation. Depends on friggframework/frigg#596 (namespacing + useDatabase). Bump @friggframework/core to that canary once published. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ee2063a09
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Add a resolve-handler test asserting a clear throw when the consumer integration has no `commands` wired (createFriggCommands missing). The failure now lands in the worker (one hop from the misconfig), so pin the actionable error. - README: document that HUBSPOT_WEBHOOK handlers must be idempotent — delivery is at-least-once (two SQS hops + HubSpot retry-on-non-2xx). 38 webhook tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Condense the receiver/resolve handler JSDoc and the bundle doc to the essential "why". Drop @this/@param/@returns boilerplate (obvious from the destructured args) and the inline comments that restated the code. No logic changes — receiver stays DB-free, resolve still does the portal lookup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
frigg#596 (extension route namespacing + useDatabase) merged to next and published as 2.0.0-next.89. Point the DB-free webhook extension at the released version instead of the canary; lockfile resynced. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
🚀 PR was released in |
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
Aligns the HubSpot webhooks extension with the new
useDatabaseflag + binding-key route namespacing in friggframework/frigg#596. The receiver is now DB-free; theportalId → integrationIdlookup moves to the queue worker via a two-hop resolve.Flow
HUBSPOT_WEBHOOK_RECEIVED(route,useDatabase: false): verify v3 signature → enqueue oneHUBSPOT_WEBHOOK_RESOLVEper event with the raw payload. No DB access.HUBSPOT_WEBHOOK_RESOLVE(queue worker, DB): runs on a dry integration instance, reverse-looks upportalId → integrationId, re-enqueuesHUBSPOT_WEBHOOKbound to that integration. Uses the framework's documented dry-instance path (createQueueWorker's no-id branch). Ambiguous resolution propagates (no cross-tenant misroute).HUBSPOT_WEBHOOK(queue worker, hydrated): consumer's bound handler runs with the correct per-account context. Default no-op.Why
Sean's requirement: the initial webhook handler should not open a DB connection. With
useDatabase: falsethe receiver Lambda doesn't even get the Prisma layer (faster cold start), and the only DB step (the lookup) lives in the worker where the DB is already available.Dependency
Requires friggframework/frigg#596 (route namespacing +
useDatabase). Until that core canary is published and this module's@friggframework/coreis bumped to it,useDatabase/namespacing are inert (old core ignores them). Land #596 → publish canary → bump core here.Test plan
HUBSPOT_WEBHOOK_RESOLVE, asserts no DB lookup, 401 paths, skip-missing-portalId, empty batch. Resolve: lookup + re-enqueue, skip-on-no-match, skip-on-missing-portalId, ambiguity propagation. Bundle shape:useDatabase: false+ 3 events.🤖 Generated with Claude Code
📦 Published PR as canary version:
Canary Versions✨ Test out this PR locally via:
npm install @friggframework/api-module-hubspot@1.1.8-canary.92.86a6bc6.0 # or yarn add @friggframework/api-module-hubspot@1.1.8-canary.92.86a6bc6.0Version
Published prerelease version:
@friggframework/api-module-hubspot@2.0.0-next.5Changelog
🚀 Enhancement
@friggframework/api-module-hubspot@friggframework/api-module-microsoft-teams,@friggframework/api-module-slack,@friggframework/api-module-42matters,@friggframework/api-module-asana,@friggframework/api-module-attio,@friggframework/api-module-clio,@friggframework/api-module-connectwise,@friggframework/api-module-contentful,@friggframework/api-module-contentstack,@friggframework/api-module-crossbeam,@friggframework/api-module-deel,@friggframework/api-module-frigg-scale-test,@friggframework/api-module-frontify,@friggframework/api-module-google-calendar,@friggframework/api-module-google-drive,@friggframework/api-module-helpscout,@friggframework/api-module-hubspot,@friggframework/api-module-ironclad,@friggframework/api-module-linear,@friggframework/api-module-pipedrive,@friggframework/api-module-salesforce,@friggframework/api-module-stripe,@friggframework/api-module-unbabel-projects,@friggframework/api-module-unbabel,@friggframework/api-module-zoho-crm,@friggframework/api-module-zoomAuthors: 1