Skip to content

v0.6.3: hubspot integration, kb block improvements#3654

Merged
waleedlatif1 merged 3 commits intomainfrom
staging
Mar 18, 2026
Merged

v0.6.3: hubspot integration, kb block improvements#3654
waleedlatif1 merged 3 commits intomainfrom
staging

Conversation

@waleedlatif1
Copy link
Collaborator

@waleedlatif1 waleedlatif1 commented Mar 18, 2026

waleedlatif1 and others added 2 commits March 18, 2026 10:34
…tools (#3651)

* fix(knowledge): infer MIME type from file extension in create/upsert tools

Both create_document and upsert_document forced .txt extension and
text/plain MIME type regardless of the document name. Now the tools
infer the correct MIME type from the file extension (html, md, csv,
json, yaml, xml) and only default to .txt when no extension is given.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(knowledge): reuse existing getMimeTypeFromExtension from uploads

Replace duplicate EXTENSION_MIME_MAP and getMimeTypeFromExtension with
the existing, more comprehensive version from lib/uploads/utils/file-utils.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(knowledge): fix btoa stack overflow and duplicate encoding in create_document

Same fixes as upsert_document: use loop-based String.fromCharCode
instead of spread, consolidate duplicate TextEncoder calls, and
check byte length instead of character length for 1MB limit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(knowledge): allowlist text-compatible MIME types in inferDocumentFileInfo

Use an explicit allowlist instead of only checking for octet-stream,
preventing binary MIME types (image/jpeg, audio/mpeg, etc.) from
leaking through when a user names a document with a binary extension.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(knowledge): remove pdf/rtf from allowlist, normalize unrecognized extensions

- Remove application/pdf and application/rtf from TEXT_COMPATIBLE_MIME_TYPES
  since these tools pass plain text content, not binary
- Normalize unrecognized extensions (e.g. report.v2) to .txt instead of
  preserving the original extension with text/plain MIME type

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(knowledge): handle dotfile names to avoid empty base in filename

Dotfiles like .env would produce an empty base, resulting in '.txt'.
Now falls back to the original name so .env becomes .env.txt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 18, 2026 6:51pm

Request Review

@waleedlatif1 waleedlatif1 changed the title v0.6.3: hubspot integration improvements v0.6.3: hubspot integration, kb block improvements Mar 18, 2026
@waleedlatif1 waleedlatif1 marked this pull request as ready for review March 18, 2026 17:55
@cursor
Copy link

cursor bot commented Mar 18, 2026

You have used all Bugbot PR reviews included in your free trial for your GitHub account on this workspace.

To continue using Bugbot reviews, enable Bugbot for your team in the Cursor dashboard.

…rors (#3634)

* fix(mothership): mothership-ran workflows show workflow validation errors

* Distinguish errors from 5xxs

* Unify workflow event handling

* Fix run from block

* Fix lint

---------

Co-authored-by: Theodore Li <theo@sim.ai>
@cursor
Copy link

cursor bot commented Mar 18, 2026

You have used all Bugbot PR reviews included in your free trial for your GitHub account on this workspace.

To continue using Bugbot reviews, enable Bugbot for your team in the Cursor dashboard.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR delivers two fixes: it adds missing HubSpot OAuth scopes (crm.objects.tickets.write, tickets, oauth) needed for ticket write operations, and it improves knowledge base document tools to infer the correct MIME type and filename from the document's file extension rather than always defaulting to text/plain / .txt.

Key changes:

  • oauth.ts / utils.ts: Three new HubSpot scopes added with descriptions. The tickets scope is a legacy v1 umbrella scope that overlaps with the newer granular crm.objects.tickets.read/crm.objects.tickets.write scopes already in the list — this may be intentional (dual-API support) but warrants a comment.
  • types.ts: New inferDocumentFileInfo helper centralises MIME-type/filename inference behind a whitelist of text-compatible types. Filenames with unrecognised or binary extensions are normalised to .txt / text/plain. A minor edge case with trailing-dot filenames (e.g. report.) could produce a double-dot filename (report..txt).
  • create_document.ts / upsert_document.ts: Both tools now call inferDocumentFileInfo and the browser-side base64 path was refactored from a spread-based String.fromCharCode(...bytes) (which would throw a stack overflow near the 1 MB limit) to a safe for loop — a good correctness fix.

Confidence Score: 4/5

  • This PR is safe to merge; the changes are targeted fixes with no critical logic errors.
  • The knowledge base MIME inference logic is well-structured and the base64 encoding fix removes a real stack-overflow risk. The OAuth change is additive. Minor style concerns exist around the redundant tickets legacy scope and a trailing-dot edge case in filename normalisation, but neither blocks functionality.
  • apps/sim/lib/oauth/oauth.ts (redundant legacy scope), apps/sim/tools/knowledge/types.ts (TEXT_COMPATIBLE_MIME_TYPES set and trailing-dot edge case)

Important Files Changed

Filename Overview
apps/sim/lib/oauth/oauth.ts Adds three HubSpot OAuth scopes: crm.objects.tickets.write, tickets (legacy v1), and oauth; the tickets scope overlaps with the granular v3 scopes already present.
apps/sim/lib/oauth/utils.ts Adds human-readable descriptions for the three new HubSpot scopes; descriptions are accurate and consistent with existing entries.
apps/sim/tools/knowledge/types.ts Introduces inferDocumentFileInfo helper that maps file extensions to MIME types via getMimeTypeFromExtension; minor edge cases with trailing-dot filenames and missing text/yaml variant noted.
apps/sim/tools/knowledge/create_document.ts Refactors base64 encoding to avoid stack overflow on large buffers and adopts inferDocumentFileInfo for dynamic MIME type/filename resolution; logic is correct.
apps/sim/tools/knowledge/upsert_document.ts Consistently applies inferDocumentFileInfo in the upsert path, mirroring the create_document changes; no new issues introduced.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["inferDocumentFileInfo(documentName)"] --> B["getFileExtension(documentName)"]
    B --> C{ext is non-empty?}
    C -- No --> F["base = documentName"]
    C -- Yes --> D["getMimeTypeFromExtension(ext)"]
    D --> E{mimeType in TEXT_COMPATIBLE_MIME_TYPES?}
    E -- Yes --> G["Return { filename: documentName, mimeType }"]
    E -- No --> H["base = documentName.slice(0, lastDot)"]
    H --> I{base is empty?}
    I -- Yes --> J["use documentName as base"]
    I -- No --> K["use base"]
    F --> L["Return { filename: base + '.txt', mimeType: 'text/plain' }"]
    J --> L
    K --> L
Loading

Last reviewed commit: "fix(mothership): mot..."

@waleedlatif1 waleedlatif1 merged commit 30f2d1a into main Mar 18, 2026
26 checks passed
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.

2 participants