Skip to content

refactor(instagram): align publishing with codebase patterns - #6270

Open
BillLeoutsakosvl346 wants to merge 5 commits into
stagingfrom
refactor/instagram-codebase-alignment
Open

refactor(instagram): align publishing with codebase patterns#6270
BillLeoutsakosvl346 wants to merge 5 commits into
stagingfrom
refactor/instagram-codebase-alignment

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Summary

  • preserve all 24 Instagram operations while standardizing publishing on canonical Sim file inputs
  • move server-only publishing behavior into a provider-local helper and keep publishing routes thin
  • remove unreleased URL/string compatibility paths and low-value configuration-restatement tests
  • keep direct Graph tools, custom Instagram OAuth, download persistence, polling, and file safety behavior intact

Why

Instagram had accumulated provider-specific input formats and duplicated server plumbing that differed from established Sim integration patterns. Because the integration is unreleased, the cleanup can remove those compatibility formats without migrations or aliases.

Validation

  • 90 focused Instagram and OAuth tests
  • Instagram deployment-availability regression suite
  • TypeScript type-check
  • format and lint checks
  • API-contract, bare-icon, client-boundary, and registry-boundary checks
  • tool metadata generation/check and integration catalog check
  • validate-integration and memory-load audit
  • independent gpt-5.6-sol max review: no remaining actionable findings

No Instagram triggers or shared platform changes are included.

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 5, 2026 7:28am

Request Review

@cursor

cursor Bot commented Aug 4, 2026

Copy link
Copy Markdown

PR Summary

Cursor Bugbot is generating a summary for commit b706259. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR standardizes Instagram publishing operations on canonical Sim file inputs and consolidates server-only media resolution and Graph publishing helpers into a provider-local module.

  • Aligns image, video, reel, story, and carousel tool parameters with shared file schemas.
  • Moves publishing lifecycle helpers behind thin authenticated API routes.
  • Updates Instagram block metadata, API contracts, generated tool metadata, and focused tests.
  • Removes unreleased URL and string compatibility paths while retaining all 24 operations.

Confidence Score: 5/5

The PR appears safe to merge, with no changed-code-triggered correctness or security failures identified.

The canonical file shapes remain consistent across block normalization, tool request construction, API contract validation, route handling, file resolution, and Graph publishing, while relocated publishing helpers preserve base-branch behavior.

Important Files Changed

Filename Overview
apps/sim/app/api/tools/instagram/server-utils.ts Consolidates server-only file resolution and Graph publishing helpers while preserving the existing publishing lifecycle.
apps/sim/lib/api/contracts/tools/instagram.ts Replaces publishing URL/string input schemas with shared canonical RawFileInput schemas and bounded file arrays.
apps/sim/blocks/blocks/instagram.ts Aligns publishing block parameters with canonical file inputs and keeps all Instagram operations registered.
apps/sim/tools/instagram/publish_carousel.ts Passes canonical file arrays directly through the carousel publishing request.
apps/sim/tools/instagram/types.ts Updates publishing parameter types to use canonical single-file and file-array representations.

Sequence Diagram

sequenceDiagram
  participant Workflow as Workflow executor
  participant Tool as Instagram publish tool
  participant Route as Publishing API route
  participant Files as Sim file storage
  participant Meta as Instagram Graph API

  Workflow->>Tool: Canonical Sim file input
  Tool->>Route: Authenticated publish request
  Route->>Files: Resolve file to signed HTTPS URL
  Files-->>Route: Signed media URL
  Route->>Meta: Create media container
  loop Until ready
    Route->>Meta: Read container status
    Meta-->>Route: IN_PROGRESS or FINISHED
  end
  Route->>Meta: Publish container
  Meta-->>Route: Published media ID
  Route-->>Tool: Container ID, media ID, status
Loading

Reviews (1): Last reviewed commit: "fix(instagram): remove stale cover strin..." | Re-trigger Greptile

…-codebase-alignment

# Conflicts:
#	apps/sim/tools/generated/tool-metadata.ts

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0f49ed3. Configure here.

condition: { field: 'operation', value: 'instagram_publish_carousel' },
mode: 'basic',
multiple: true,
hideFromCopilot: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot hide marks media private

Low Severity

Setting hideFromCopilot on carouselMediaUpload also adds carouselMedia to privateInputIds via the serializer, so carousel media is stripped from execution logs. Sibling Instagram publish uploads do not use this flag, and it is otherwise reserved for server-managed secrets like mothership secret scope.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0f49ed3. Configure here.

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

Instagram architecture classification

This classifies the final Instagram integration after the compatibility cleanup.

  • Standard: files expected for an ordinary Sim integration.
  • Semi-standard: established extension points needed for provider-specific OAuth or file-backed operations.
  • Unique: Instagram-specific infrastructure without an existing repository pattern.

Standard

Block

  • apps/sim/blocks/blocks/instagram.ts

The normal integration block containing the 24 operations, conditional fields, parameter mapping, and output declarations.

Publishing now uses the standard canonical file pair:

  • Basic mode: Sim file upload/selection.
  • Advanced mode: reference a file from an earlier block.
  • Carousel publishing: reference an ordered array such as <previousBlock.files>.

The basic carousel picker is hidden only from Copilot metadata because Mothership should use the advanced array reference. The human editor remains unchanged. This is provider configuration inside the conventional block definition, not new platform infrastructure.

Tools

  • apps/sim/tools/instagram/constants.ts
  • apps/sim/tools/instagram/delete_comment.ts
  • apps/sim/tools/instagram/download_media.ts
  • apps/sim/tools/instagram/get_account_insights.ts
  • apps/sim/tools/instagram/get_container_status.ts
  • apps/sim/tools/instagram/get_conversation_messages.ts
  • apps/sim/tools/instagram/get_media.ts
  • apps/sim/tools/instagram/get_media_insights.ts
  • apps/sim/tools/instagram/get_message.ts
  • apps/sim/tools/instagram/get_profile.ts
  • apps/sim/tools/instagram/get_publishing_limit.ts
  • apps/sim/tools/instagram/hide_comment.ts
  • apps/sim/tools/instagram/index.ts
  • apps/sim/tools/instagram/list_comments.ts
  • apps/sim/tools/instagram/list_conversations.ts
  • apps/sim/tools/instagram/list_media.ts
  • apps/sim/tools/instagram/list_stories.ts
  • apps/sim/tools/instagram/output-properties.ts
  • apps/sim/tools/instagram/private_reply.ts
  • apps/sim/tools/instagram/publish_carousel.ts
  • apps/sim/tools/instagram/publish_image.ts
  • apps/sim/tools/instagram/publish_reel.ts
  • apps/sim/tools/instagram/publish_story.ts
  • apps/sim/tools/instagram/publish_video.ts
  • apps/sim/tools/instagram/reply_to_comment.ts
  • apps/sim/tools/instagram/send_text_message.ts
  • apps/sim/tools/instagram/set_comments_enabled.ts
  • apps/sim/tools/instagram/types.ts
  • apps/sim/tools/instagram/utils.ts

These follow the conventional tools/<provider> organization: one file per operation plus small provider-local types, outputs, constants, and request/response helpers.

Registration and generated metadata

  • apps/sim/blocks/registry-maps.ts
  • apps/sim/tools/registry.ts
  • apps/sim/lib/integrations/integrations.json
  • apps/sim/components/icons.tsx
  • apps/sim/tools/generated/tool-ids.ts
  • apps/sim/tools/generated/tool-metadata.ts
  • apps/sim/tools/generated/tool-outputs.ts

These are ordinary integration registry, icon, and generated-catalog files.

Semi-standard

File-backed publishing and download routes

  • apps/sim/app/api/tools/instagram/publish-image/route.ts
  • apps/sim/app/api/tools/instagram/publish-video/route.ts
  • apps/sim/app/api/tools/instagram/publish-reel/route.ts
  • apps/sim/app/api/tools/instagram/publish-story/route.ts
  • apps/sim/app/api/tools/instagram/publish-carousel/route.ts
  • apps/sim/app/api/tools/instagram/download-media/route.ts
  • apps/sim/app/api/tools/instagram/server-utils.ts
  • apps/sim/lib/api/contracts/tools/instagram.ts

These routes are required because publishing must:

  • Authorize access to Sim workspace files.
  • Validate Instagram-supported file types and sizes.
  • Produce provider-accessible media URLs.
  • Create and poll Instagram media containers.
  • Convert downloaded binary media into Sim UserFile outputs.

Other file-backed integrations use internal routes for the same reasons. The routes remain thin, while shared Instagram publishing behavior is colocated in one provider-local server helper. No service framework or generic operation router was added.

Instagram-specific OAuth flow

  • apps/sim/app/api/auth/instagram/authorize/route.ts
  • apps/sim/app/api/auth/oauth2/callback/instagram/route.ts
  • apps/sim/lib/oauth/instagram.ts
  • apps/sim/lib/oauth/index.ts
  • apps/sim/lib/oauth/oauth.ts
  • apps/sim/lib/oauth/types.ts
  • apps/sim/lib/oauth/utils.ts

Instagram requires Meta’s authorization flow, short-lived token exchange, long-lived token exchange, account discovery, and proactive refresh behavior. Dedicated provider routes/helpers are therefore justified, just as other nonstandard OAuth providers have their own provider-specific handling.

This belongs with the Instagram integration because the integration cannot connect or refresh credentials correctly without it. It does not change OAuth behavior for unrelated providers.

Cloud-storage capability check

  • apps/sim/app/api/files/storage-status/route.ts
  • apps/sim/lib/core/config/env-capabilities.ts

Instagram publishing requires media that Meta can retrieve from a public provider-accessible URL. The existing capability check prevents presenting publishing as available when the local deployment has no compatible cloud storage.

This is an established platform capability check rather than an Instagram-specific storage implementation.

Unique

There are no remaining unique Instagram runtime files.

The cleanup removed:

  • Legacy public-URL file inputs.
  • JSON and comma-separated carousel compatibility formats.
  • video: carousel prefixes.
  • Duplicate file-shape sniffing.
  • Redundant contract tests.
  • The narrowly named resolve-media helper in favor of the clearer provider-local server-utils helper.

Instagram has no background jobs, custom execution queues, database tables, migrations, webhook architecture, or shared framework changes.

Tests retained

  • apps/sim/app/api/tools/instagram/download-media/route.test.ts
  • apps/sim/app/api/tools/instagram/server-utils.test.ts
  • apps/sim/blocks/blocks/instagram.test.ts
  • apps/sim/lib/oauth/instagram.test.ts
  • apps/sim/tools/instagram/get_conversation_messages.test.ts
  • apps/sim/tools/instagram/get_publishing_limit.test.ts
  • apps/sim/tools/instagram/utils.test.ts

These cover behavior that is easy to regress:

  • Graph request construction and bounded parsing.
  • OAuth exchange and refresh.
  • Publishing-file authorization and validation.
  • Container polling and provider faults.
  • Download persistence and rollback.
  • Cross-operation parameter isolation.
  • Advanced carousel file-array normalization.
  • Insights input handling.

The standalone contract-restatement test and duplicated malformed-response/configuration assertions were removed.

Result

The final Instagram implementation preserves all 24 operations while using conventional tools, canonical file inputs, thin authenticated routes for genuine binary/server work, and provider-local OAuth handling. No unique shared architecture remains.

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.

1 participant