-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Hubspot - fix run only on page on first run #18294
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 GitHub. 2 Skipped Deployments
|
WalkthroughHubSpot sources: removed the default "1 day ago" fallback for stored Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Scheduler
participant Source as HubSpot Source
participant DB as DB
participant HubSpot as HubSpot API
Scheduler->>Source: run()
Source->>DB: get("after")
DB-->>Source: after (may be undefined)
alt after is falsy (initial run)
Source->>HubSpot: fetch page 1 (params with DEFAULT_LIMIT)
HubSpot-->>Source: results page 1
Note over Source: Early return after first page
Source->>DB: set("after", last timestamp from page 1)
else after exists (subsequent runs)
loop paginate until exhausted
Source->>HubSpot: fetch next page (using after/hasMore)
HubSpot-->>Source: results page N
Source->>DB: update "after"
end
end
sequenceDiagram
autonumber
participant Source as New/Updated Contact
participant DB as DB
participant HubSpot as HubSpot API
Source->>DB: get("after")
DB-->>Source: after (may be undefined)
Note over Source: getParams always sets limit = DEFAULT_LIMIT
Source->>HubSpot: search/scroll contacts with params
HubSpot-->>Source: contacts batch
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type 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 (3)
components/hubspot/sources/common/common.mjs (3)
16-18: Removing the fallback in _getAfter() is appropriate.This guarantees a true initial run when no cursor exists. Consider normalizing to null (not required).
95-99: Guard should distinguish null/undefined from 0.Using
!aftertreats0as “first run”. Prefer a nullish check to avoid misclassification.- // first run, get only first page - if (!after) { + // first run = after is null/undefined; get only first page + if (after == null) { return; }
137-141: Same nullish check in paginateUsingHasMore.Mirror the fix to ensure consistent initial-run behavior.
- // first run, get only first page - if (!after) { + // first run = after is null/undefined + if (after == null) { return; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
components/hubspot/sources/common/common.mjs(3 hunks)components/hubspot/sources/new-or-updated-contact/new-or-updated-contact.mjs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
components/hubspot/sources/new-or-updated-contact/new-or-updated-contact.mjs (2)
components/hubspot/hubspot.app.mjs (2)
DEFAULT_LIMIT(35-41)DEFAULT_LIMIT(587-592)components/hubspot/common/constants.mjs (1)
DEFAULT_LIMIT(40-40)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Lint Code Base
🔇 Additional comments (1)
components/hubspot/sources/new-or-updated-contact/new-or-updated-contact.mjs (1)
105-118: Always using DEFAULT_LIMIT is correct and consistent with first-run pagination.This aligns with the new “first page only on initial run” behavior in common.mjs. No issues found.
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 (2)
components/hubspot/sources/new-custom-object-property-change/new-custom-object-property-change.mjs (2)
54-83: Guard against undefinedafterin filters (aligns with new first-run semantics)If
getParams(after)is called with a falsyafter, HubSpot may receivevalue: undefined. To be resilient (even if common’s paginator early-returns), include thehs_lastmodifieddatefilter only whenafteris truthy.- getParams(after) { - return { - object: this.objectSchema, - data: { - limit: DEFAULT_LIMIT, - properties: [ - this.property, - ], - sorts: [ - { - propertyName: "hs_lastmodifieddate", - direction: "DESCENDING", - }, - ], - filterGroups: [ - { - filters: [ - { - propertyName: this.property, - operator: "HAS_PROPERTY", - }, - { - propertyName: "hs_lastmodifieddate", - operator: "GTE", - value: after, - }, - ], - }, - ], - }, - }; - }, + getParams(after) { + const filters = [ + { propertyName: this.property, operator: "HAS_PROPERTY" }, + ]; + if (after) { + filters.push({ + propertyName: "hs_lastmodifieddate", + operator: "GTE", + value: after, + }); + } + return { + object: this.objectSchema, + data: { + limit: DEFAULT_LIMIT, + properties: [ this.property ], + sorts: [ + { propertyName: "hs_lastmodifieddate", direction: "DESCENDING" }, + ], + filterGroups: [ { filters } ], + }, + }; + },
32-38: Harden timestamp handling to avoidNaNIDsIf HubSpot returns an unexpected timestamp,
Date.parse(...)can beNaN, producing IDs like${id}NaN. SafeguardgetTsand use a stable fallback forid.- getTs(object) { - const history = object.propertiesWithHistory[this.property]; - if (!history || !(history.length > 0)) { - return; - } - return Date.parse(history[0].timestamp); - }, + getTs(object) { + const history = object.propertiesWithHistory?.[this.property]; + if (!history || history.length === 0) return; + const ts = new Date(history[0]?.timestamp).getTime(); + return Number.isNaN(ts) ? undefined : ts; + }, @@ - return { - id: `${id}${ts}`, + return { + id: `${id}-${ts ?? Date.now()}`, summary: properties[this.property], ts, };Also applies to: 45-49
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (25)
components/hubspot/package.json(1 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(2 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 (23)
- components/hubspot/sources/new-or-updated-product/new-or-updated-product.mjs
- components/hubspot/sources/new-social-media-message/new-social-media-message.mjs
- components/hubspot/sources/new-or-updated-custom-object/new-or-updated-custom-object.mjs
- components/hubspot/sources/new-or-updated-crm-object/new-or-updated-crm-object.mjs
- components/hubspot/sources/new-email-subscriptions-timeline/new-email-subscriptions-timeline.mjs
- components/hubspot/sources/new-or-updated-blog-article/new-or-updated-blog-article.mjs
- components/hubspot/sources/new-email-event/new-email-event.mjs
- components/hubspot/sources/new-engagement/new-engagement.mjs
- components/hubspot/sources/new-or-updated-deal/new-or-updated-deal.mjs
- components/hubspot/sources/new-event/new-event.mjs
- components/hubspot/package.json
- components/hubspot/sources/new-or-updated-company/new-or-updated-company.mjs
- components/hubspot/sources/new-company-property-change/new-company-property-change.mjs
- components/hubspot/sources/new-or-updated-line-item/new-or-updated-line-item.mjs
- components/hubspot/sources/new-ticket/new-ticket.mjs
- components/hubspot/sources/new-form-submission/new-form-submission.mjs
- components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs
- components/hubspot/sources/new-note/new-note.mjs
- components/hubspot/sources/delete-blog-article/delete-blog-article.mjs
- components/hubspot/sources/new-deal-property-change/new-deal-property-change.mjs
- components/hubspot/sources/new-ticket-property-change/new-ticket-property-change.mjs
- components/hubspot/sources/new-task/new-task.mjs
- components/hubspot/sources/new-contact-property-change/new-contact-property-change.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
- components/hubspot/sources/new-or-updated-contact/new-or-updated-contact.mjs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
- GitHub Check: Lint Code Base
🔇 Additional comments (2)
components/hubspot/sources/new-custom-object-property-change/new-custom-object-property-change.mjs (2)
9-9: Version bump only — LGTMMetadata bump to 0.0.13 is fine.
100-120: No action needed — initial pagination only requests first page
ThegetParams(after)in new-custom-object-property-change doesn’t include any top-levelaftertoken (it only sets filterGroups forhs_lastmodifieddate), so on first run withafter = undefinedthe initial API call has no paging cursor. The sharedgetPaginatedItemshelper then does a singledo…whileloop that only continues ifpaging.next.afteris truthy, ensuring only page 1 is fetched initially.
|
Hi everyone, all test cases are passed! Ready for release! Test report |
WHY
Summary by CodeRabbit
Bug Fixes
Refactor