Repository navigation
Conversation
|
@zain2983 is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
Create or update up to 100 contacts in one request, matched by email or a custom unique property, through HubSpot's batch upsert endpoint. One invalid contact rejects the whole batch. With a custom unique ID property and an objectWriteTraceId on every contact, HubSpot saves the valid ones and answers 207; the tool returns those errors with success false instead of dropping them.
Found by running the block through Sim's executor against a HubSpot developer test account: - dry run: return success, numErrors and errors; without them Sim's sampler filled numErrors with 900000001 - refuse before sending, naming the contact's position: a repeated id (email compared without case; HubSpot answered "Contact already exists"), trace IDs on only some contacts or repeated, a non-object entry, a non-text id or trace ID, a property that contradicts the id - report the size of an oversized batch - say that partial success (objectWriteTraceId on every contact) needs a custom unique ID Property: HubSpot's guide does not support partial upserts with email - give the block its own ID Property field for Upsert Contacts, with the right placeholder, and restore the shared placeholder - json-array generation for the Contacts wand - document that results come back in no guaranteed order Tests cover each guard; 10 of the 15 fail against the previous tool.
zain2983
force-pushed
the
feat/hubspot-upsert-contacts
branch
from
December 5, 2026 01:08
c762513 to
e9cd299
Compare
zain2983
marked this pull request as ready for review
December 5, 2026 05:39
This branch has not been deployed
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 #10777
Summary
Adds
hubspot_upsert_contacts(HubSpot block operation Upsert Contacts): create or update up to 100 contacts in one call toPOST /crm/v3/objects/contacts/batch/upsert, matched byemail(default) or a custom unique property.Why: syncing a list of contacts today means one search plus one create-or-update per contact, and a retry can create a duplicate between the search and the create. The batch upsert makes the same call safe to repeat.
objectWriteTraceIdon every contact, HubSpot saves the valid contacts and returns 207; the tool reportserrors,numErrorsandsuccess: false(the step itself completes, so branch onsuccess). Withemail, HubSpot's contacts guide says partial upserts are not supported, and production portals answer 400 to trace IDs ("Cannot perform a partial upsert with email"): one invalid contact rejects the whole batch. The tool's descriptions say so; it does not block trace IDs withemail, so HubSpot's own error reaches the user.idand apropertiesobject, no repeated id (email compared without case), trace IDs on all contacts or none and all distinct, and no property that contradicts the id. The 100 limit is HubSpot's; the repeated-id and trace-ID rules come from a HubSpot developer test account, where HubSpot answered 400 (for a repeated email, with the vaguer "Contact already exists"). HubSpot's reference doesn't state them.dryRunOutputreturns the previewed contacts plussuccess: true,numErrors: 0,errors: [](without them Sim's sampler fillednumErrorswith900000001).objectWriteTraceId.emailas ID Property returned 207 and saved the valid contact, twice. Treat that as the exception, not the contract (see above).Product update (if relevant)
HubSpot users can sync a list of contacts in one step without searching first to decide between create and update. No rollout or plan restriction in Sim. Docs: the HubSpot integration page.
Type of Change
Testing
macOS arm64, Bun 1.4.4, Node 24.
In the product. Sim built from this branch, run in dev mode against its own Postgres (pgvector) and Redis. A synthetic user and workspace were created with Sim's auth routes. The HubSpot credential is Sim's own HubSpot service key credential type (
sim credentials create hubspot-service-account), holding a private-app token for a HubSpot developer test account; no OAuth app was involved. The workflow (Start, HubSpot Upsert Contacts, Response) was written with the workflow SDK and run through Sim's executor withsim workflows run --manual(dry run:sim workflows run --dry). Synthetic contacts only (@example.com, phones+1 201-555-01xx); all were archived afterwards. Each result was checked in HubSpot with a batch read, not from the tool's output alone.new: truejobtitleonlynew: false, other properties kepterrorswith its trace ID,success: falseemailID Property, trace IDs on all, one invalididProperty(a test property created for this)success/numErrors/errors(this showed the900000001bug, fixed)idPropertynullidPropertyNot run live: a real 429 or 5xx. Sim's executor throws on a non-2xx response with HubSpot's message before the tool's response code runs, so the tool has no code of its own for them. The live runs were on the tree before the last wording-only edits (descriptions and comments); the code paths they exercise did not change.
Run output was read from the CLI and checked in HubSpot; the workflow was not run from the UI.
Gate, after the final rebase onto
stagingat6b9613a1:bun run generate(clean tree),lint:check,type-check,check:auditsandcheck-block-registry origin/stagingpassed. HubSpot and block tests: 27 passed, of whichupsert_contacts.test.tsis 15; 10 of those 15 fail against the previous version of the tool.Full suite (
turbo run test --continue --concurrency=1), run onstagingatb0e9ae17, two staging commits before the final rebase (neither touches HubSpot, the registries or generated tool files): 24 of 25 tasks passed (@sim/app3,887 files and 46,421 tests passed, 13 skipped;sim1,412;@sim/realtime194;@sim/workflow-code846). The one failure is@sim/desktop, which cannot build its native module here (no C headers for this Node); this change does not touch it. Not rerun after the last rebase.Checklist
Screenshots/Videos
None yet.