- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
Hubspot - Use Bottleneck for all requests #15398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
 | 
| WalkthroughThis pull request introduces a rate-limiting mechanism to the HubSpot integration by implementing Bottleneck in the  Changes
 Assessment against linked issues
 Possibly related PRs
 Suggested labels
 Suggested reviewers
 Poem
 Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit: 
 Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
 Other keywords and placeholders
 CodeRabbit Configuration File ( | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
components/hubspot/hubspot.app.mjs (1)
16-21: Centralized rate limiter setup looks good.
Instantiating a Bottleneck limiter and wrapping axios should provide consistent rate-limiting across the app.Consider using built-in retry or backoff options to handle 429 rate limit errors gracefully, in case HubSpot’s limit is exceeded.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
- pnpm-lock.yamlis excluded by- !**/pnpm-lock.yaml
📒 Files selected for processing (49)
- components/hubspot/actions/add-contact-to-list/add-contact-to-list.mjs(1 hunks)
- components/hubspot/actions/batch-create-or-update-contact/batch-create-or-update-contact.mjs(1 hunks)
- components/hubspot/actions/create-associations/create-associations.mjs(1 hunks)
- components/hubspot/actions/create-communication/create-communication.mjs(1 hunks)
- components/hubspot/actions/create-company/create-company.mjs(1 hunks)
- components/hubspot/actions/create-custom-object/create-custom-object.mjs(1 hunks)
- components/hubspot/actions/create-deal/create-deal.mjs(1 hunks)
- components/hubspot/actions/create-engagement/create-engagement.mjs(1 hunks)
- components/hubspot/actions/create-lead/create-lead.mjs(1 hunks)
- components/hubspot/actions/create-or-update-contact/create-or-update-contact.mjs(1 hunks)
- components/hubspot/actions/create-ticket/create-ticket.mjs(1 hunks)
- components/hubspot/actions/enroll-contact-into-workflow/enroll-contact-into-workflow.mjs(1 hunks)
- components/hubspot/actions/get-company/get-company.mjs(1 hunks)
- components/hubspot/actions/get-contact/get-contact.mjs(1 hunks)
- components/hubspot/actions/get-deal/get-deal.mjs(1 hunks)
- components/hubspot/actions/get-file-public-url/get-file-public-url.mjs(1 hunks)
- components/hubspot/actions/search-crm/search-crm.mjs(1 hunks)
- components/hubspot/actions/update-company/update-company.mjs(1 hunks)
- components/hubspot/actions/update-contact/update-contact.mjs(1 hunks)
- components/hubspot/actions/update-custom-object/update-custom-object.mjs(1 hunks)
- components/hubspot/actions/update-deal/update-deal.mjs(1 hunks)
- components/hubspot/actions/update-lead/update-lead.mjs(1 hunks)
- components/hubspot/hubspot.app.mjs(2 hunks)
- components/hubspot/package.json(1 hunks)
- components/hubspot/sources/common/common.mjs(2 hunks)
- components/hubspot/sources/delete-blog-article/delete-blog-article.mjs(1 hunks)
- components/hubspot/sources/new-company-property-change/new-company-property-change.mjs(1 hunks)
- components/hubspot/sources/new-contact-property-change/new-contact-property-change.mjs(1 hunks)
- components/hubspot/sources/new-custom-object-property-change/new-custom-object-property-change.mjs(1 hunks)
- components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs(1 hunks)
- components/hubspot/sources/new-deal-property-change/new-deal-property-change.mjs(1 hunks)
- components/hubspot/sources/new-email-event/new-email-event.mjs(1 hunks)
- components/hubspot/sources/new-email-subscriptions-timeline/new-email-subscriptions-timeline.mjs(1 hunks)
- components/hubspot/sources/new-engagement/new-engagement.mjs(1 hunks)
- components/hubspot/sources/new-event/new-event.mjs(1 hunks)
- components/hubspot/sources/new-form-submission/new-form-submission.mjs(1 hunks)
- components/hubspot/sources/new-note/new-note.mjs(1 hunks)
- components/hubspot/sources/new-or-updated-blog-article/new-or-updated-blog-article.mjs(1 hunks)
- components/hubspot/sources/new-or-updated-company/new-or-updated-company.mjs(1 hunks)
- components/hubspot/sources/new-or-updated-contact/new-or-updated-contact.mjs(1 hunks)
- components/hubspot/sources/new-or-updated-crm-object/new-or-updated-crm-object.mjs(1 hunks)
- components/hubspot/sources/new-or-updated-custom-object/new-or-updated-custom-object.mjs(1 hunks)
- components/hubspot/sources/new-or-updated-deal/new-or-updated-deal.mjs(1 hunks)
- components/hubspot/sources/new-or-updated-line-item/new-or-updated-line-item.mjs(1 hunks)
- components/hubspot/sources/new-or-updated-product/new-or-updated-product.mjs(1 hunks)
- components/hubspot/sources/new-social-media-message/new-social-media-message.mjs(1 hunks)
- components/hubspot/sources/new-task/new-task.mjs(1 hunks)
- components/hubspot/sources/new-ticket-property-change/new-ticket-property-change.mjs(1 hunks)
- components/hubspot/sources/new-ticket/new-ticket.mjs(1 hunks)
✅ Files skipped from review due to trivial changes (45)
- components/hubspot/sources/new-ticket-property-change/new-ticket-property-change.mjs
- components/hubspot/sources/new-or-updated-custom-object/new-or-updated-custom-object.mjs
- components/hubspot/sources/new-or-updated-blog-article/new-or-updated-blog-article.mjs
- components/hubspot/actions/create-engagement/create-engagement.mjs
- components/hubspot/actions/update-contact/update-contact.mjs
- components/hubspot/sources/new-task/new-task.mjs
- components/hubspot/sources/new-ticket/new-ticket.mjs
- components/hubspot/actions/update-company/update-company.mjs
- components/hubspot/package.json
- components/hubspot/actions/create-ticket/create-ticket.mjs
- components/hubspot/sources/new-engagement/new-engagement.mjs
- components/hubspot/sources/new-email-subscriptions-timeline/new-email-subscriptions-timeline.mjs
- components/hubspot/sources/new-form-submission/new-form-submission.mjs
- components/hubspot/actions/create-company/create-company.mjs
- components/hubspot/actions/create-deal/create-deal.mjs
- components/hubspot/actions/get-file-public-url/get-file-public-url.mjs
- components/hubspot/actions/add-contact-to-list/add-contact-to-list.mjs
- components/hubspot/sources/new-or-updated-product/new-or-updated-product.mjs
- components/hubspot/actions/create-custom-object/create-custom-object.mjs
- components/hubspot/actions/create-communication/create-communication.mjs
- components/hubspot/actions/update-custom-object/update-custom-object.mjs
- components/hubspot/actions/get-contact/get-contact.mjs
- components/hubspot/sources/new-or-updated-company/new-or-updated-company.mjs
- components/hubspot/sources/new-or-updated-contact/new-or-updated-contact.mjs
- components/hubspot/sources/delete-blog-article/delete-blog-article.mjs
- components/hubspot/sources/new-event/new-event.mjs
- components/hubspot/sources/new-email-event/new-email-event.mjs
- components/hubspot/sources/new-custom-object-property-change/new-custom-object-property-change.mjs
- components/hubspot/sources/new-company-property-change/new-company-property-change.mjs
- components/hubspot/actions/get-deal/get-deal.mjs
- components/hubspot/actions/update-lead/update-lead.mjs
- components/hubspot/actions/enroll-contact-into-workflow/enroll-contact-into-workflow.mjs
- components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs
- components/hubspot/sources/new-social-media-message/new-social-media-message.mjs
- components/hubspot/actions/search-crm/search-crm.mjs
- components/hubspot/actions/update-deal/update-deal.mjs
- components/hubspot/sources/new-note/new-note.mjs
- components/hubspot/actions/get-company/get-company.mjs
- components/hubspot/sources/new-deal-property-change/new-deal-property-change.mjs
- components/hubspot/sources/new-or-updated-deal/new-or-updated-deal.mjs
- components/hubspot/sources/new-or-updated-crm-object/new-or-updated-crm-object.mjs
- components/hubspot/sources/new-contact-property-change/new-contact-property-change.mjs
- components/hubspot/actions/batch-create-or-update-contact/batch-create-or-update-contact.mjs
- components/hubspot/sources/new-or-updated-line-item/new-or-updated-line-item.mjs
- components/hubspot/actions/create-associations/create-associations.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: pnpm publish
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
🔇 Additional comments (7)
components/hubspot/sources/common/common.mjs (2)
71-71: Confirm request throttling strategy.
By removing the rate limiter here, this loop may now send API requests in a tight loop without throttling, which could risk hitting rate limits if the new limiter isn’t applied upstream.Ensure that the request logic in
hubspot.app.mjsfully protects this paging process from overloading HubSpot’s rate limits.
109-109: Maintain consistency in pagination approach.
This line parallels the logic at line 71. Double-check that removing the old rate-limiting mechanism doesn’t result in undesired behavior (e.g., spamming requests).Would you like me to generate a script to scan for unthrottled function calls in the codebase?
components/hubspot/hubspot.app.mjs (1)
482-482: 🛠️ Refactor suggestionVerify correct usage of wrapped axios.
CallingaxiosRateLimiter($, { … })ensures controlled concurrency. Confirm all critical methods use this wrapper instead of raw axios calls.You could run a repository-wide search for direct axios usage to ensure all calls route through the limiter.
components/hubspot/actions/create-or-update-contact/create-or-update-contact.mjs (2)
9-9: Version bump looks consistentThe version bump from
0.0.14to0.0.15aligns with the coordinated release across multiple HubSpot actions.
Line range hint
12-17: Ensure logic is implemented for the newupdateIfExistspropThe newly introduced boolean prop
updateIfExistssuggests the action should handle an error from the HubSpot create call and attempt an update if this prop is enabled. However, no supporting logic here or incommon.methods(as far as shown) confirms this behavior.Would you like me to propose sample error-handling code to fully implement this feature?
components/hubspot/actions/create-lead/create-lead.mjs (2)
12-12: Version increment validatedThe jump from
0.0.4to0.0.5is in line with the broader versioning updates across the HubSpot suite.
Line range hint
23-45: Confirm robust handling ofcontactIdassociationThe added association block correctly targets
this.contactIdfor linking a contact to the new lead. However, consider validating thatthis.contactIdis defined and valid before making the API request. This helps avoid unexpected errors if the prop is empty or invalid.Below is a suggestion for a mild safeguard:
createObject(opts) { + if (!this.contactId) { + throw new Error("A valid Contact ID is required to associate the lead"); + } return this.hubspot.createObject({ ...✅ Verification successful
The review comment's validation suggestion is appropriate and necessary
The contactId validation is indeed missing and should be added. While the prop is properly defined using HubSpot's objectId propDefinition, an explicit validation before creating the association would prevent orphaned leads and provide clearer error messages to users.
The suggested code change is a good safeguard:
createObject(opts) { + if (!this.contactId) { + throw new Error("A valid Contact ID is required to associate the lead"); + } return this.hubspot.createObject({ ...🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
#!/bin/bash # Get the complete create-lead component implementation cat components/hubspot/actions/create-lead/create-lead.mjs # Search for similar contact association patterns in other HubSpot components rg -l "associationTypeId.*578" components/hubspot/ # Check HubSpot client implementation for object creation fd "hubspot.*\.(js|mjs)$" components/hubspot/common/ -x cat {}Length of output: 1650
Script:
#!/bin/bash # Check the common create object implementation cat components/hubspot/actions/common/common-create-object.mjsLength of output: 3115
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @michelle0927, LGTM! Ready for QA!
Resolves #15393
Summary by CodeRabbit
Version Updates
New Features
Minor Changes
updateIfExistsproperty to contact creation actionThese updates represent minor improvements and version maintenance for the HubSpot integration.