Skip to content

improvement(buffer): explicit mediaType override instead of guessing on ambiguous media - #5642

Merged
waleedlatif1 merged 5 commits into
stagingfrom
worktree-buffer-integration
Jul 13, 2026
Merged

improvement(buffer): explicit mediaType override instead of guessing on ambiguous media#5642
waleedlatif1 merged 5 commits into
stagingfrom
worktree-buffer-integration

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Follow-up to feat(buffer): add Buffer integration with posts, channels, and ideas #5637 (merged before this landed): addresses Greptile's final P1 about silent media-type guessing
  • Adds a mediaType param (auto | image | video, default auto) to buffer_create_post / buffer_edit_post, the route contract, and the block (advanced dropdown)
  • In auto mode, when the MIME type, URL extension, and DNS-pinned HEAD probe are all inconclusive, the route now returns a clear 400 asking for an explicit mediaType instead of defaulting the asset to image

Type of Change

  • Improvement

Testing

Typecheck, lint, check:api-validation:strict pass; docs regenerated

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercelBot commented Jul 13, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
docsSkippedSkippedJul 13, 2026 8:42pm

Request Review

@cursor

cursorBot commented Jul 13, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes media classification (may break ambiguous URLs that silently worked as images) and broadens presigned URL lifetime for Buffer only; file-utils behavior for keyed uploads is stricter about reminting URLs.

Overview
Adds mediaType (auto | image | video, default auto) to Buffer create/edit post flows—API contracts, routes, tools, block advanced UI, and docs—so callers can force attachment kind when MIME, extension, and HEAD probe are inconclusive. Auto mode no longer guesses image; the route returns a 400 with a clear message to set mediaType explicitly.

For scheduled/queued posts, Buffer media resolution now requests 7-day presigned URLs (via configurable presignExpirySeconds on file resolution), and stored files with a key always get a freshly minted presign at that TTL instead of reusing possibly stale embedded URLs. Docs note that uploads are link-valid for 7 days and public URLs are better for longer schedules.

Reviewed by Cursor Bugbot for commit 8770cd5. Configure here.

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

Comment threadapps/sim/app/api/tools/buffer/create-post/route.ts
Comment threadapps/sim/app/api/tools/buffer/create-post/route.ts
@greptile-apps

greptile-appsBot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds explicit Buffer media type handling for ambiguous attachments. The main changes are:

  • mediaType is exposed on the Buffer create and edit tools.
  • Create and edit routes forward mediaType into media resolution.
  • Explicit image and video values skip auto-detection.
  • Ambiguous auto media now returns a clear request error.
  • Stored Buffer media URLs use a longer presign window.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

FilenameOverview
apps/sim/app/api/tools/buffer/create-post/route.tsThe create route now forwards the validated media type into the shared Buffer mutation helper.
apps/sim/app/api/tools/buffer/edit-post/route.tsThe edit route now forwards the validated media type into the shared Buffer mutation helper.
apps/sim/app/api/tools/buffer/server-utils.tsMedia resolution now honors explicit attachment types, rejects inconclusive auto-detection, and uses longer presigned links for Buffer media.
apps/sim/lib/api/contracts/tools/buffer.tsThe shared Buffer contract now accepts auto, image, and video media type values.
apps/sim/lib/uploads/utils/file-utils.server.tsStored file URL resolution now supports caller-provided presign expiry values.
apps/sim/tools/buffer/create_post.tsThe create tool now exposes and sends the media type option.
apps/sim/tools/buffer/edit_post.tsThe edit tool now exposes and sends the media type option.
apps/sim/tools/buffer/types.tsBuffer create and edit parameter types now include the media type option.
apps/sim/blocks/blocks/buffer.tsThe Buffer block now includes an advanced media type dropdown.
apps/docs/content/docs/en/integrations/buffer.mdxThe Buffer docs now describe the media type option and uploaded media link lifetime.

Reviews (8): Last reviewed commit: "fix(buffer): always mint fresh presigned..." | Re-trigger Greptile

Comment threadapps/sim/app/api/tools/buffer/create-post/route.ts
Comment threadapps/sim/app/api/tools/buffer/edit-post/route.ts
@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Buffer as a social scheduling integration. The main changes are:

  • New Buffer block, tool registry entries, icons, and docs.
  • New Buffer GraphQL tool implementations for posts, channels, ideas, and account data.
  • New create/edit post API routes with media resolution and explicit mediaType support.
  • Updated API validation contracts for Buffer post mutations.

Confidence Score: 4/5

The Buffer create/edit media path needs a fix before merging.

  • Explicit image/video overrides are validated and sent by the tools.
  • The create and edit routes drop that value before calling the media resolver.
  • Ambiguous media can still fail with the new error even when callers provide the override.

apps/sim/app/api/tools/buffer/create-post/route.ts, apps/sim/app/api/tools/buffer/edit-post/route.ts

Important Files Changed

FilenameOverview
apps/sim/app/api/tools/buffer/create-post/route.tsAdds a contract-bound create route, but drops the validated mediaType before media resolution.
apps/sim/app/api/tools/buffer/edit-post/route.tsAdds a contract-bound edit route, but drops the validated mediaType before media replacement.
apps/sim/app/api/tools/buffer/server-utils.tsAdds Buffer post mutation forwarding and media auto-detection with support for explicit image/video overrides.
apps/sim/blocks/blocks/buffer.tsAdds the Buffer block definition, operations, media fields, templates, and parameter mapping.
apps/sim/lib/api/contracts/tools/buffer.tsAdds shared create/edit post route contracts with scheduling and media validation.
apps/sim/tools/buffer/create_post.tsAdds the create-post tool and sends Buffer create requests through the internal route.
apps/sim/tools/buffer/edit_post.tsAdds the edit-post tool and sends Buffer edit requests through the internal route.
apps/sim/tools/buffer/types.tsAdds shared Buffer GraphQL selections, types, response mapping, and error handling helpers.

Reviews (2): Last reviewed commit: "improvement(buffer): explicit mediaType ..." | Re-trigger Greptile

Comment threadapps/sim/app/api/tools/buffer/create-post/route.ts
Comment threadapps/sim/app/api/tools/buffer/edit-post/route.ts
@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile review

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

Comment threadapps/sim/app/api/tools/buffer/server-utils.ts
@waleedlatif1
waleedlatif1force-pushed the worktree-buffer-integration branch from 96ee382 to c5ecd7aCompareJuly 13, 2026 20:10
@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile review

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c5ecd7a. Configure here.

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile review

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

Comment threadapps/sim/app/api/tools/buffer/server-utils.ts
@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile review

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

Comment threadapps/sim/lib/uploads/utils/file-utils.server.ts
@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile review

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8770cd5. Configure here.

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@waleedlatif1
waleedlatif1 merged commit e7afe45 into stagingJul 13, 2026
18 checks passed
@waleedlatif1
waleedlatif1 deleted the worktree-buffer-integration branch July 13, 2026 21:48
Sign up for freeto 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.

1 participant

@waleedlatif1