Skip to content

feat(chat): migrate POST /api/sandbox/upload to api#1744

Closed
arpitgupta1214 wants to merge 4 commits into
testfrom
feature/sandbox-staged-files-cutover
Closed

feat(chat): migrate POST /api/sandbox/upload to api#1744
arpitgupta1214 wants to merge 4 commits into
testfrom
feature/sandbox-staged-files-cutover

Conversation

@arpitgupta1214
Copy link
Copy Markdown
Collaborator

@arpitgupta1214 arpitgupta1214 commented May 9, 2026

Summary

Cutover for the sandbox upload token handshake. lib/sandboxes/uploadSandboxFiles.ts now points handleUploadUrl at \${getClientApiBaseUrl()}/api/sandboxes/staged-files (the new api route from api#541) and the local /api/sandbox/upload route is deleted. The downstream commit step (POST /api/sandboxes/files) is unchanged.

Closes Group 6 of the chat→api migration. Merge order: api → docs → chat.

Test plan

  • On a preview where api is on the matching branch, drop a file into the sandbox file picker; confirm the Vercel Blob handshake hits api (not chat) and the file commits to the sandbox repo
  • Verify the OPTIONS preflight succeeds from chat.recoupable.com against api.recoupable.com

Summary by cubic

Moves the sandbox upload handshake from chat to api and removes the local /api/sandbox/upload route. Points handleUploadUrl to ${getClientApiBaseUrl()}/api/sandboxes/staged-file and sends auth via Authorization: Bearer; the commit step (POST /api/sandboxes/files) is unchanged.

  • Migration
    • Merge order: api → docs → chat; requires POST /api/sandboxes/staged-file.
    • Verify uploads hit api and commit, CORS preflight succeeds, and the Authorization header is accepted.

Written for commit 6982d75. Summary will update on new commits.

Flips `handleUploadUrl` in lib/sandboxes/uploadSandboxFiles.ts from
the local /api/sandbox/upload route to the new
${getClientApiBaseUrl()}/api/sandboxes/staged-files on api, then
deletes the now-unused local route.

Closes Group 6 of the chat→api migration. Pairs with api PR for
the staged-files handler and docs PR for the OpenAPI entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 9, 2026

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

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview May 9, 2026 5:37pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

Warning

Rate limit exceeded

@arpitgupta1214 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 6 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 701bd4b4-e77f-4f6a-a010-b8968f0808a2

📥 Commits

Reviewing files that changed from the base of the PR and between 9e94db1 and 6982d75.

📒 Files selected for processing (2)
  • app/api/sandbox/upload/route.ts
  • lib/sandboxes/uploadSandboxFiles.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/sandbox-staged-files-cutover

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Migrates upload token handshake from chat to api, altering critical path for file uploads. Requires human review to verify API endpoint, CORS, and migration order.

Pairs with the api-side rename of /api/sandboxes/staged-files to
/api/sandboxes/stage-files.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/sandboxes/uploadSandboxFiles.ts">

<violation number="1" location="lib/sandboxes/uploadSandboxFiles.ts:43">
P1: The upload handshake endpoint path was changed to `/api/sandboxes/stage-files`, but the migrated API route is `/api/sandboxes/staged-files`. This typo will break sandbox file uploads.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread lib/sandboxes/uploadSandboxFiles.ts Outdated
const blob = await upload(file.name, file, {
access: "public",
handleUploadUrl: "/api/sandbox/upload",
handleUploadUrl: `${getClientApiBaseUrl()}/api/sandboxes/stage-files`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: The upload handshake endpoint path was changed to /api/sandboxes/stage-files, but the migrated API route is /api/sandboxes/staged-files. This typo will break sandbox file uploads.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At lib/sandboxes/uploadSandboxFiles.ts, line 43:

<comment>The upload handshake endpoint path was changed to `/api/sandboxes/stage-files`, but the migrated API route is `/api/sandboxes/staged-files`. This typo will break sandbox file uploads.</comment>

<file context>
@@ -40,7 +40,7 @@ export async function uploadSandboxFiles({
       const blob = await upload(file.name, file, {
         access: "public",
-        handleUploadUrl: `${getClientApiBaseUrl()}/api/sandboxes/staged-files`,
+        handleUploadUrl: `${getClientApiBaseUrl()}/api/sandboxes/stage-files`,
         clientPayload: JSON.stringify({ token: accessToken }),
       });
</file context>
Suggested change
handleUploadUrl: `${getClientApiBaseUrl()}/api/sandboxes/stage-files`,
handleUploadUrl: `${getClientApiBaseUrl()}/api/sandboxes/staged-files`,

Pairs with the api-side rename to the noun-shaped resource path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Vercel Blob client's upload() supports a `headers` option that
forwards arbitrary headers onto the handshake POST — replacing the
clientPayload.token dance with a normal Bearer header. Pairs with
the api-side switch to validateAuthContext().

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

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