Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Dec 5, 2024

Resolves #14856

Summary by CodeRabbit

  • New Features

    • Introduced a new method to trim string values in objects and arrays, enhancing data formatting before API requests.
  • Bug Fixes

    • Improved compliance with HubSpot's validation rules by ensuring string values are trimmed before requests.
  • Chores

    • Updated the package version from 0.10.1 to 0.10.2.
    • Incremented version numbers for various actions and sources within the HubSpot integration.

@vercel
Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 7:17pm
pipedream-docs ⬜️ Ignored (Inspect) Dec 5, 2024 7:17pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Dec 5, 2024 7:17pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Walkthrough

The pull request introduces a new method, trimStringValues, to the hubspot.app.mjs file, which recursively trims whitespace from string values in objects, arrays, or strings. This method is integrated into the existing makeRequest method to ensure that all string values are trimmed before API requests are sent, aligning with HubSpot's upcoming validation rules. Additionally, the version numbers for several modules and the @pipedream/hubspot package are updated to reflect these changes.

Changes

File Change Summary
components/hubspot/hubspot.app.mjs Added method trimStringValues to trim string values recursively. Modified makeRequest to use trimStringValues for data and params.
components/hubspot/package.json Updated version from 0.10.1 to 0.10.2.
components/hubspot/actions/add-contact-to-list/add-contact-to-list.mjs Updated version from 0.0.10 to 0.0.11.
components/hubspot/actions/batch-create-or-update-contact/batch-create-or-update-contact.mjs Updated version from 0.0.7 to 0.0.8.
components/hubspot/actions/create-associations/create-associations.mjs Updated version from 0.0.10 to 0.0.11.
components/hubspot/actions/create-communication/create-communication.mjs Updated version from 0.0.2 to 0.0.3.
components/hubspot/actions/create-company/create-company.mjs Updated version from 0.0.13 to 0.0.14.
components/hubspot/actions/create-custom-object/create-custom-object.mjs Updated version from 0.0.1 to 0.0.2.
components/hubspot/actions/create-deal/create-deal.mjs Updated version from 0.0.13 to 0.0.14.
components/hubspot/actions/create-engagement/create-engagement.mjs Updated version from 0.0.12 to 0.0.13.
components/hubspot/actions/create-lead/create-lead.mjs Updated version from 0.0.1 to 0.0.2 and added method createObject.
components/hubspot/actions/create-or-update-contact/create-or-update-contact.mjs Updated version from 0.0.11 to 0.0.12 and added property updateIfExists.
components/hubspot/actions/create-ticket/create-ticket.mjs Updated version from 0.0.4 to 0.0.5.
components/hubspot/actions/enroll-contact-into-workflow/enroll-contact-into-workflow.mjs Updated version from 0.0.10 to 0.0.11.
components/hubspot/actions/get-company/get-company.mjs Updated version from 0.0.10 to 0.0.11.
components/hubspot/actions/get-contact/get-contact.mjs Updated version from 0.0.10 to 0.0.11.
components/hubspot/actions/get-deal/get-deal.mjs Updated version from 0.0.10 to 0.0.11 and updated property description for objectId.
components/hubspot/actions/get-file-public-url/get-file-public-url.mjs Updated version from 0.0.10 to 0.0.11.
components/hubspot/actions/search-crm/search-crm.mjs Updated version from 0.0.8 to 0.0.9.
components/hubspot/actions/update-company/update-company.mjs Updated version from 0.0.9 to 0.0.10.
components/hubspot/actions/update-contact/update-contact.mjs Updated version from 0.0.10 to 0.0.11.
components/hubspot/actions/update-custom-object/update-custom-object.mjs Updated version from 0.0.1 to 0.0.2 and added property objectId.
components/hubspot/actions/update-lead/update-lead.mjs Updated version from 0.0.1 to 0.0.2.
components/hubspot/sources/delete-blog-article/delete-blog-article.mjs Updated version from 0.0.15 to 0.0.16.
components/hubspot/sources/new-company-property-change/new-company-property-change.mjs Updated version from 0.0.8 to 0.0.9.
components/hubspot/sources/new-contact-property-change/new-contact-property-change.mjs Updated version from 0.0.10 to 0.0.11.
components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs Updated version from 0.0.19 to 0.0.20.
components/hubspot/sources/new-deal-property-change/new-deal-property-change.mjs Updated version from 0.0.9 to 0.0.10.
components/hubspot/sources/new-email-event/new-email-event.mjs Updated version from 0.0.18 to 0.0.19.
components/hubspot/sources/new-email-subscriptions-timeline/new-email-subscriptions-timeline.mjs Updated version from 0.0.15 to 0.0.16.
components/hubspot/sources/new-engagement/new-engagement.mjs Updated version from 0.0.20 to 0.0.21.
components/hubspot/sources/new-event/new-event.mjs Updated version from 0.0.19 to 0.0.20.
components/hubspot/sources/new-form-submission/new-form-submission.mjs Updated version from 0.0.20 to 0.0.21.
components/hubspot/sources/new-or-updated-blog-article/new-or-updated-blog-article.mjs Updated version from 0.0.2 to 0.0.3.
components/hubspot/sources/new-or-updated-company/new-or-updated-company.mjs Updated version from 0.0.2 to 0.0.3 and added property newOnly.
components/hubspot/sources/new-or-updated-contact/new-or-updated-contact.mjs Updated version from 0.0.2 to 0.0.3.
components/hubspot/sources/new-or-updated-crm-object/new-or-updated-crm-object.mjs Updated version from 0.0.15 to 0.0.16.
components/hubspot/sources/new-or-updated-custom-object/new-or-updated-custom-object.mjs Updated version from 0.0.4 to 0.0.5.
components/hubspot/sources/new-or-updated-deal/new-or-updated-deal.mjs Updated version from 0.0.2 to 0.0.3.
components/hubspot/sources/new-or-updated-line-item/new-or-updated-line-item.mjs Updated version from 0.0.2 to 0.0.3 and added property newOnly.
components/hubspot/sources/new-or-updated-product/new-or-updated-product.mjs Updated version from 0.0.2 to 0.0.3 and added property newOnly.
components/hubspot/sources/new-social-media-message/new-social-media-message.mjs Updated version from 0.0.15 to 0.0.16.
components/hubspot/sources/new-ticket-property-change/new-ticket-property-change.mjs Updated version from 0.0.9 to 0.0.10.
components/hubspot/sources/new-ticket/new-ticket.mjs Updated version from 0.0.15 to 0.0.16.

Assessment against linked issues

Objective Addressed Explanation
Update logic to trim whitespace on non-string property values (#14856)

Possibly related PRs

  • Hubspot version update #14816: This PR updates the version number of the @pipedream/hubspot package in the package.json file, which is related to the main PR as both involve changes to the HubSpot components.

Suggested reviewers

  • GTFalcao

🐇 In the code where we play and hop,
Trim the strings, let no whitespace stop!
With every request, neat and bright,
HubSpot's rules, we’ll get it right!
Version updated, let’s take our leap,
Into the future, our data will keep! 🌟


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
components/hubspot/hubspot.app.mjs (1)

456-464: Compatibility considerations with Object.fromEntries

Object.fromEntries is an ES2019 feature and may not be supported in environments targeting older JavaScript versions. If backward compatibility is a concern, consider replacing it.

Replace Object.fromEntries with a compatible alternative:

- return Object.fromEntries(
-   Object.entries(obj).map(([key, value]) => [
-     key,
-     this.trimStringValues(value),
-   ]),
- );
+ const trimmedObj = {};
+ for (const [key, value] of Object.entries(obj)) {
+   trimmedObj[key] = this.trimStringValues(value);
+ }
+ return trimmedObj;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d110209 and dbfd006.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • components/hubspot/hubspot.app.mjs (1 hunks)
  • components/hubspot/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/hubspot/package.json
🔇 Additional comments (1)
components/hubspot/hubspot.app.mjs (1)

479-480: Verify that trimming does not affect non-string values in data and params

Applying trimStringValues to data and params ensures string values are trimmed, but ensure that non-string values are not inadvertently modified or removed.

Double-check that numeric, boolean, null, and other non-string values remain unchanged after processing.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (7)
components/hubspot/actions/create-lead/create-lead.mjs (1)

Line range hint 41-41: Consider moving the association type ID to constants

The hardcoded ID 578 for "Lead with Primary Contact" should be moved to the constants file for better maintainability.

- associationTypeId: 578, // ID for "Lead with Primary Contact"
+ associationTypeId: ASSOCIATION_TYPE.LEAD_TO_PRIMARY_CONTACT,

Consider adding this to common/constants.mjs:

export const ASSOCIATION_TYPE = {
  LEAD_TO_PRIMARY_CONTACT: 578,
};
components/hubspot/actions/search-crm/search-crm.mjs (1)

Line range hint 67-71: Add whitespace trimming for search values

To comply with HubSpot's upcoming validation changes (April 7th, 2025), the search value should be trimmed before being used in the filters array. While the new trimStringValues method in hubspot.app.mjs will handle the final request, it's better to trim the search value early to ensure consistent behavior.

Suggested change:

      filters: [
        {
          propertyName: searchProperty,
          operator: "EQ",
-         value: searchValue,
+         value: searchValue.trim(),
        },
      ],

Also applies to: 155-161

components/hubspot/sources/new-or-updated-company/new-or-updated-company.mjs (1)

Line range hint 30-36: Consider extracting filtering logic

The newOnly property and its related logic seem to be part of a different feature set. Consider moving these changes to a separate PR focused on event filtering improvements.

components/hubspot/sources/new-or-updated-product/new-or-updated-product.mjs (2)

Line range hint 30-36: Consider extracting common source functionality

The newOnly property and its related logic are duplicated across multiple source files. Consider:

  1. Creating a shared mixin or base class for source components
  2. Moving the timestamp and ID generation logic to the common module

This would improve maintainability and reduce code duplication.

Example approach:

// common/source-mixin.mjs
export const sourceMixin = {
  props: {
    newOnly: {
      type: "boolean",
      label: "New Only",
      description: "Emit events only for new items",
      default: false,
      optional: true,
    },
  },
  methods: {
    getTs(item) {
      return this.newOnly
        ? Date.parse(item.createdAt)
        : Date.parse(item.updatedAt);
    },
    generateMetaId(id, ts) {
      return this.newOnly ? id : `${id}-${ts}`;
    },
  },
};

Also applies to: 38-52


Line range hint 1-1: PR changes don't address stated objectives

The current changes focus on adding event filtering capabilities and updating component versions, but don't implement the whitespace trimming functionality required for Hubspot's API breaking change (April 7th, 2025). The PR should include:

  1. Implementation of whitespace trimming for non-string property values
  2. Unit tests for the trimming functionality
  3. Documentation updates about the breaking change

Consider:

  • Splitting the current changes into a separate PR for event filtering
  • Creating a new PR focused on the whitespace trimming requirement
components/hubspot/actions/create-engagement/create-engagement.mjs (2)

Line range hint 89-103: Add whitespace trimming before creating engagement

The properties object is spread directly into the create request without any whitespace handling. This could lead to 400 errors after April 7th, 2025, when Hubspot enforces stricter validation.

Consider adding whitespace trimming before the engagement creation:

    if (properties.hs_task_reminders) {
      properties.hs_task_reminders = Date.parse(properties.hs_task_reminders);
    }

+   // Trim whitespace from non-string property values before sending to API
+   const trimmedProperties = hubspot.trimPropertyValues(properties);
 
-   const engagement = await this.createEngagement(objectType, properties, associations, $);
+   const engagement = await this.createEngagement(objectType, trimmedProperties, associations, $);

Line range hint 1-1: ❌ PR does not fulfill its objectives

This PR aims to update validation logic for Hubspot's upcoming API changes (April 7th, 2025) by trimming whitespace from non-string property values. However, the implementation is missing across all components. The changes only include version bumps and unrelated property additions.

Key missing elements:

  1. No implementation of whitespace trimming logic
  2. No updates to property validation before API calls
  3. No tests to verify the whitespace handling

Recommendation:

  1. Implement a central utility function for trimming whitespace from non-string properties
  2. Apply this function in all components that send data to Hubspot's API
  3. Add tests to verify the whitespace handling
  4. Consider reverting version bumps until the actual changes are implemented

Would you like assistance in implementing the whitespace trimming utility and its integration across components?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dbfd006 and 599ad53.

📒 Files selected for processing (42)
  • 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-lead/update-lead.mjs (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-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-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-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 (33)
  • components/hubspot/sources/new-form-submission/new-form-submission.mjs
  • components/hubspot/sources/new-engagement/new-engagement.mjs
  • components/hubspot/actions/add-contact-to-list/add-contact-to-list.mjs
  • components/hubspot/sources/new-ticket/new-ticket.mjs
  • components/hubspot/actions/create-company/create-company.mjs
  • components/hubspot/sources/new-social-media-message/new-social-media-message.mjs
  • components/hubspot/actions/enroll-contact-into-workflow/enroll-contact-into-workflow.mjs
  • components/hubspot/actions/get-company/get-company.mjs
  • components/hubspot/actions/get-contact/get-contact.mjs
  • components/hubspot/sources/new-deal-property-change/new-deal-property-change.mjs
  • components/hubspot/actions/create-associations/create-associations.mjs
  • components/hubspot/actions/create-custom-object/create-custom-object.mjs
  • components/hubspot/sources/new-or-updated-crm-object/new-or-updated-crm-object.mjs
  • components/hubspot/sources/new-or-updated-deal/new-or-updated-deal.mjs
  • components/hubspot/actions/update-company/update-company.mjs
  • components/hubspot/actions/get-file-public-url/get-file-public-url.mjs
  • components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs
  • components/hubspot/sources/new-or-updated-blog-article/new-or-updated-blog-article.mjs
  • components/hubspot/actions/update-contact/update-contact.mjs
  • components/hubspot/actions/create-ticket/create-ticket.mjs
  • components/hubspot/sources/new-ticket-property-change/new-ticket-property-change.mjs
  • components/hubspot/sources/new-or-updated-contact/new-or-updated-contact.mjs
  • components/hubspot/sources/new-event/new-event.mjs
  • components/hubspot/actions/create-deal/create-deal.mjs
  • components/hubspot/actions/batch-create-or-update-contact/batch-create-or-update-contact.mjs
  • components/hubspot/sources/new-company-property-change/new-company-property-change.mjs
  • components/hubspot/actions/update-lead/update-lead.mjs
  • components/hubspot/sources/new-contact-property-change/new-contact-property-change.mjs
  • components/hubspot/actions/get-deal/get-deal.mjs
  • components/hubspot/sources/new-or-updated-custom-object/new-or-updated-custom-object.mjs
  • components/hubspot/sources/new-email-event/new-email-event.mjs
  • components/hubspot/sources/delete-blog-article/delete-blog-article.mjs
  • components/hubspot/sources/new-email-subscriptions-timeline/new-email-subscriptions-timeline.mjs
🔇 Additional comments (11)
components/hubspot/actions/create-lead/create-lead.mjs (2)

12-12: LGTM: Version bump is appropriate

The version increment reflects the changes in validation logic while maintaining backward compatibility.


Line range hint 33-50: Verify whitespace trimming for API compliance

While this component uses the hubspot app's createObject method, we should verify that all property values are properly trimmed before reaching Hubspot's API to comply with the April 2025 breaking change.

✅ Verification successful

Based on the results, I can generate the final response as we have sufficient information about the whitespace trimming implementation.

Whitespace trimming is properly implemented

The trimStringValues function is correctly implemented in hubspot.app.mjs and is applied to both data and params before making API requests. The implementation recursively trims strings in:

  • Simple string values
  • Arrays (maps over elements)
  • Objects (processes all values)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that trimStringValues is called before API requests
# Expected: Find usage of trimStringValues in the request chain

# Check if trimStringValues is used in the app's request handling
ast-grep --pattern 'createObject($params) {
  $$$
  trimStringValues($$$)
  $$$
}'

# Verify the implementation in hubspot.app.mjs
rg -A 5 "trimStringValues" 

Length of output: 1590

components/hubspot/actions/update-custom-object/update-custom-object.mjs (3)

Line range hint 23-31: Verify whitespace handling for objectId property

Given Hubspot's upcoming strict validation rules, ensure that:

  1. The objectId value is properly processed by the new trimStringValues method
  2. Error handling is in place for IDs containing whitespace
✅ Verification successful

Whitespace handling for objectId is properly implemented

The verification shows that:

  1. The trimStringValues method is comprehensively implemented to handle string values, arrays, and objects recursively
  2. All request data is automatically processed through trimStringValues via the makeRequest method
  3. Since objectId is passed as part of the request data, it will be automatically trimmed before being sent to the HubSpot API
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how objectId is processed in the request chain
# Look for objectId usage in the request flow
echo "Checking objectId handling:"
ast-grep --pattern 'objectId' components/hubspot/hubspot.app.mjs
rg -A 5 'trimStringValues.*objectId' components/hubspot/

Length of output: 583


Script:

#!/bin/bash
# Let's check the implementation of trimStringValues and how object IDs are processed
echo "Checking trimStringValues implementation:"
rg -A 10 "trimStringValues" components/hubspot/

echo -e "\nChecking update-custom-object implementation:"
cat components/hubspot/actions/update-custom-object/update-custom-object.mjs

Length of output: 3366


Line range hint 1-1: Verify common update object functionality compatibility

Since this component relies on common update object functionality, ensure that:

  1. The common module properly integrates with the new whitespace validation logic
  2. Any shared validation or error handling is updated accordingly

9-9: Verify version consistency across dependent components

The version bump is appropriate, but let's ensure all related components are updated consistently to maintain compatibility with the new whitespace validation logic.

✅ Verification successful

Version bump is inconsistent with related components

The version bump to "0.0.2" for update-custom-object appears inconsistent with related components. Looking at the results:

  • create-custom-object is at version "0.0.2"
  • Most other action components are at higher versions (0.0.8 - 0.0.14)
  • Components that handle CRM objects and custom objects:
    • new-or-updated-custom-object source is at "0.0.5"
    • new-or-updated-crm-object source is at "0.0.16"

Let's verify if these components share the same validation logic:


Version bump to 0.0.2 is appropriate

The version bump from 0.0.1 to 0.0.2 is appropriate for the following reasons:

  • Both update-custom-object and create-custom-object components are at version 0.0.2, maintaining consistency between related components
  • The components share common functionality through common-create-object.mjs, which handles property transformations uniformly
  • The whitespace validation is handled at the app level (hubspot.app.mjs) which these components import, making this a non-breaking change
  • The version differences with other components (0.0.8-0.0.14) are justified as those components have gone through more iterations and feature additions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check version numbers across Hubspot components to ensure consistency
# Look for any version declarations in Hubspot component files
echo "Checking component versions:"
fd . components/hubspot -t f -e mjs -e json | xargs rg "version.*0\.0\." -A 1

Length of output: 7887


Script:

#!/bin/bash
# Check for trimStringValues usage in these components
echo "Checking trimStringValues usage:"
rg "trimStringValues" components/hubspot/actions/update-custom-object/update-custom-object.mjs components/hubspot/actions/create-custom-object/create-custom-object.mjs -A 2 -B 2

Length of output: 252


Script:

#!/bin/bash
# Let's check the actual implementation of these components to see how they handle properties
echo "Checking property handling in custom object components:"
rg "properties.*=" components/hubspot/actions/update-custom-object/update-custom-object.mjs components/hubspot/actions/create-custom-object/create-custom-object.mjs -A 5 -B 5

echo -e "\nChecking app.mjs imports and usage:"
rg "import.*hubspot" components/hubspot/actions/update-custom-object/update-custom-object.mjs components/hubspot/actions/create-custom-object/create-custom-object.mjs -A 2

Length of output: 1165


Script:

#!/bin/bash
# Let's check the common module and how properties are handled across these components
echo "Checking common module implementation:"
cat components/hubspot/actions/common/common-create-object.mjs

echo -e "\nChecking run method implementations:"
ast-grep --pattern 'async run({ $$ }) {
  $$$
}' components/hubspot/actions/update-custom-object/update-custom-object.mjs components/hubspot/actions/create-custom-object/create-custom-object.mjs

Length of output: 3098

components/hubspot/actions/search-crm/search-crm.mjs (3)

18-18: LGTM: Version bump is appropriate.

The version increment from 0.0.8 to 0.0.9 appropriately reflects the changes being made to handle the upcoming HubSpot API validation requirements.


Line range hint 1-179: Recommend thorough testing with whitespace-containing values

Given HubSpot's upcoming validation changes (April 7th, 2025), please ensure comprehensive testing of this component with:

  1. Search values containing leading/trailing whitespace
  2. Property values containing whitespace during object creation
  3. Various object types to verify consistent behavior

This will help ensure a smooth transition when the stricter validation rules take effect.


Line range hint 164-175: Verify whitespace handling during object creation

When creating new objects, we need to ensure that the properties are properly handled according to HubSpot's new validation rules.

Let's verify that the createObject method in hubspot.app.mjs properly implements the new trimStringValues method:

✅ Verification successful

Based on the gathered information, I can now generate the final response:

Whitespace handling is properly implemented through the global request pipeline

The makeRequest method in hubspot.app.mjs automatically applies trimStringValues to both data and params before making any request:

makeRequest({
  $ = this,
  api,
  endpoint,
  data,
  params,
  ...otherOpts
}) {
  return axios($, {
    url: `${BASE_URL}${api}${endpoint}`,
    headers: this._getHeaders(),
    data: data && this.trimStringValues(data),
    params: params && this.trimStringValues(params),
    ...otherOpts,
  });
}

Since createObject uses makeRequest internally, all property values will be automatically trimmed before being sent to HubSpot's API, ensuring proper whitespace handling during object creation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that createObject method uses trimStringValues
# Expected: Find implementation showing that createObject uses trimStringValues

ast-grep --pattern 'createObject($$$) {
  $$$
  trimStringValues($$$)
  $$$
}'

Length of output: 80


Script:

#!/bin/bash
# Let's first check if trimStringValues exists in hubspot.app.mjs
rg -A 5 "trimStringValues" 

# Also search for createObject implementation
ast-grep --pattern 'createObject($$$) {
  $$$
}'

# Additionally check for any property handling in createObject
rg -A 10 "createObject" 

Length of output: 14785


Script:

#!/bin/bash
# Let's check how makeRequest is implemented since createObject uses it
rg -A 10 "makeRequest.*{" components/hubspot/hubspot.app.mjs

# Also check if there are any direct property transformations in the search-crm.mjs
rg -A 5 "properties" components/hubspot/actions/search-crm/search-crm.mjs

Length of output: 1610


Script:

#!/bin/bash
# Let's check the makeRequest implementation with proper regex
rg -A 10 "makeRequest\s*\(" components/hubspot/hubspot.app.mjs

# Also check if there's any data transformation before making the request
rg -B 5 -A 10 "method: \"POST\"" components/hubspot/hubspot.app.mjs

Length of output: 11892

components/hubspot/actions/create-or-update-contact/create-or-update-contact.mjs (1)

9-9: Verify version bump implications

The version has been bumped from 0.0.11 to 0.0.12. Please ensure this version increment aligns with semantic versioning principles, considering the breaking changes in the Hubspot API that this PR addresses.

✅ Verification successful

Version bump appears consistent with component patterns

The version increment from 0.0.11 to 0.0.12 in create-or-update-contact.mjs follows the established versioning pattern seen across the Hubspot component, where most actions and sources use similar 0.0.x versioning. The change appears to be a standard minor version bump consistent with adding new functionality (the updateIfExists property).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for other version changes in the codebase
rg -g '*.mjs' -g '*.js' '"version": "0.0.1' .

Length of output: 47


Script:

#!/bin/bash
# Let's try a different pattern to search for version strings
rg -g '*.mjs' -g '*.js' 'version: "[0-9]+\.[0-9]+\.[0-9]+"' .

Length of output: 65978


Script:

#!/bin/bash
# Let's check for version changes in the Hubspot component specifically
rg -g '*.mjs' '"version": "0.0.' ./components/hubspot/

Length of output: 56


Script:

#!/bin/bash
# Let's try a broader search pattern for the Hubspot component
rg -g '*.mjs' 'version:' ./components/hubspot/

Length of output: 3974

components/hubspot/sources/new-or-updated-line-item/new-or-updated-line-item.mjs (1)

12-12: ⚠️ Potential issue

Version update may be premature without whitespace handling

The version bump to 0.0.3 is present, but I don't see any changes related to the PR's objective of handling whitespace trimming for non-string property values. This component processes line item data and should include the whitespace handling changes to prevent 400 errors after April 7th, 2025.

Let's verify if the whitespace handling is implemented in a parent class or common utility:

✅ Verification successful

Version bump is appropriate as whitespace handling is already implemented

The version bump is justified because:

  1. The component inherits from the common module and uses the Hubspot app
  2. The Hubspot app already implements whitespace trimming via the trimStringValues method
  3. This trimming is automatically applied to all API requests through the makeRequest method
  4. The implementation follows Hubspot's validation rules for non-string properties

The whitespace handling is properly implemented at the app level, ensuring all components, including this line item source, benefit from the functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for whitespace trimming implementation in related files
echo "Searching for whitespace handling in common files..."
rg -l "trim.*whitespace|trim.*space" --type js components/hubspot/common/
rg -l "trim.*whitespace|trim.*space" --type js components/hubspot/hubspot.app.mjs

Length of output: 274


Script:

#!/bin/bash
# Let's check for any recent changes in this file and related files
echo "Checking recent changes in the line item source..."
git show HEAD -- components/hubspot/sources/new-or-updated-line-item/new-or-updated-line-item.mjs

echo "Searching for any trim-related functions in the codebase..."
rg -A 5 "\.trim\(|trimEnd|trimStart" components/hubspot/

echo "Looking for string processing in the app or common files..."
ast-grep --pattern 'function $FUNC($_) { $$$ String $$$ }'  components/hubspot/

Length of output: 1893


Script:

#!/bin/bash
# Let's examine the trimStringValues implementation in hubspot.app.mjs
echo "Checking trimStringValues implementation..."
rg -B 5 -A 10 "trimStringValues" components/hubspot/hubspot.app.mjs

# Let's also check if this component extends or uses the hubspot app
echo "Checking component's relationship with hubspot.app.mjs..."
rg -A 3 "hubspot.app" components/hubspot/sources/new-or-updated-line-item/new-or-updated-line-item.mjs

Length of output: 1713


Script:

#!/bin/bash
# Let's check the imports and app usage in the line item source
echo "Checking imports in the line item source..."
head -n 20 components/hubspot/sources/new-or-updated-line-item/new-or-updated-line-item.mjs

# Let's also check if there are any API calls that would need trimming
echo "Checking API calls in the line item source..."
rg "\.makeRequest|hubspot\.(post|put|patch)" components/hubspot/sources/new-or-updated-line-item/new-or-updated-line-item.mjs

Length of output: 1019

components/hubspot/actions/create-engagement/create-engagement.mjs (1)

12-12: ⚠️ Potential issue

Missing whitespace handling for engagement properties

The version is updated, but the implementation doesn't address the PR's objective of trimming whitespace from non-string property values. This is critical for engagement creation as it processes various properties that could contain whitespace.

Let's verify the property types being processed:

Copy link
Collaborator

@luancazarine luancazarine left a 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!

@michelle0927 michelle0927 merged commit 685bb65 into master Dec 11, 2024
11 checks passed
@michelle0927 michelle0927 deleted the issue-14856 branch December 11, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Hubspot - Update validation logic to comply with breaking change

3 participants