Skip to content

fix(agent): stop asking the API for a projectless upload URL it does not serve - #5678

Merged
kojiwakayama merged 2 commits into
mainfrom
fix/inbox-4939-projectless-upload-url
Dec 4, 2026
Merged

kojiwakayama merged 2 commits into
mainfrom
fix/inbox-4939-projectless-upload-url

Conversation

@kojiwakayama

Copy link
Copy Markdown
Contributor

Problem

For a chat without a project, the runtime asked veryfront-api for an attachment's signed URL at GET /uploads/{upload_id}/url. The API has no such route, so the call always answered 404. The attachment was then dropped with only the warning Hosted chat attachment unreadable; continuing without it, after a request that could never succeed.

Refs veryfront/veryfront-issue-inbox#4939

Root cause

createRuntimeUploadUrl in src/agent/runtime/upload-url-client.ts fell back to a root /uploads/{id}/url path when the run had no project. That path is a leftover of a contract the API retired:

  • veryfront-api removed the root uploads REST API in 4ccb3b5e68 ("Remove deprecated root uploads REST API", with the directive not to reintroduce root upload aliases without a migration contract for project ownership).
  • veryfront-api removed default personal projects and the legacy user-scoped upload resolution in 8382857e38 ("project-scoped only").
  • On veryfront-api main (da11a89768) every code path that creates an upload row takes a project id (create-or-update-upload.ts, create-project-upload-with-folders.ts, import-project-upload-attachment.ts, and external-storage/import.ts, which refuses without a project). upload.project_id is still nullable, but only for legacy rows.

So the API has no project-free model to read from, and the fix belongs in veryfront-code, not in a new API route.

Fix

getRuntimeUploadUrl rejects with invalid-argument before any request when it has no projectId (undefined, null or empty). The only URL it builds is /projects/{project}/uploads/{upload}/url.

Nothing changes for the caller's degrade path in resolveRuntimeMessageFileUrls: the upload becomes a reference-only part plus an [attachment unavailable: <name>] text part, so the model knows a file was there, and onUnresolvableAttachment logs the warning. RuntimeUploadUrlOptions.projectId stays optional, so the public type is unchanged.

Tests

Both fail on main (e545fb689) with "https://api.example.com/uploads/upload-1/url" in the requested URLs, and pass with the fix:

  • src/agent/runtime/upload-url-client.test.ts: without a project (undefined, null, "") the call rejects with invalid-argument and sends no request. This replaces the test that pinned the root /uploads/{id}/url call.
  • src/agent/hosted/chat-preparation.test.ts: prepareHostedChatRuntimeMessages with projectId: null sends nothing to the API, reports the upload once through onUnresolvableAttachment, and gives the model [attachment unavailable: notes.pdf].

Run locally (Deno 2.9.8; the repository pins 2.9.7):

  • deno task test:file src/agent/runtime (921 passed)
  • deno task test:file src/agent/hosted/chat-preparation.test.ts (76 passed)
  • deno task test:file src/agent/service (155 passed)
  • deno task lint, deno task lint:test-typecheck, deno task lint:style, deno fmt --check on the changed files, deno check src/agent/index.ts

Not run: deno task docs:api-reference:check, which needs the pinned Deno 2.9.7. The exported names and their JSDoc summaries are unchanged.

Not in this PR

  • The row in veryfront-api. GET /uploads/{upload_id}/url in src/api/shared/auth/projectless-run-token-surface.ts (added in veryfront/veryfront-api#7941, still open) has no caller after this change and can go. On veryfront-api main the surface still admits the whole /uploads prefix.
  • Studio. studio/lib/chat/uploadChatDataFiles.ts and server/mcp/tools/media/displayMediaLogic.ts in veryfront-studio still call the root /uploads alias for a chat without a project. That is where a projectless chat fails to get an upload id in the first place, and it is a separate change.
  • Attachments in a chat without a project. Whether such a chat should be able to carry a file at all (for example, by naming the upload's project on the message part) is a product decision. This PR only stops the request that cannot succeed.

🤖 Generated with Claude Code

…not serve

veryfront-api signs an upload only under its project
(GET /projects/{project}/uploads/{upload}/url). The root /uploads routes
were removed there and uploads are project-bound. For a run without a
project the runtime still built GET /uploads/{upload}/url, which always
answered 404.

getRuntimeUploadUrl now rejects with invalid-argument before any request
when it has no project. The hosted chat keeps its existing degrade: the
attachment becomes a reference-only part plus an
"[attachment unavailable: ...]" note, and the warning is logged.

Refs veryfront/veryfront-issue-inbox#4939

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T15:26:08.297841Z 0708d9b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

@codex review

Copy link
Copy Markdown
Contributor

Score: 86/100. A small, well-scoped fix. It stops a request that could never succeed and leaves the existing degrade path unchanged.

  • Strength: correct root cause and placement. The guard in getRuntimeUploadUrl runs before any I/O, and createRuntimeUploadUrl now requires projectId: string, so the type checker blocks a root /uploads/{id}/url path from returning. The only internal caller (src/agent/hosted/chat-preparation.ts:1061) passes the error to onUnresolvableAttachment, the same route the old 404 took, so hosted chat behaves the same apart from the wasted request.
  • Strength: tests. The parameterized undefined / null / "" cases check both "no request sent" and the invalid-argument slug. The new prepareHostedChatRuntimeMessages test covers the full degrade path, including the [attachment unavailable: notes.pdf] part the model sees. The removed test only pinned the dead route, so removing it is correct.
  • Concern (minor): public behavior change with an unchanged signature. getRuntimeUploadUrl is exported from veryfront/agent (docs/api-reference/veryfront/agent.md:835), and RuntimeUploadUrlOptions.projectId stays optional. A type-correct call without a project now throws every time. Before, it reached the network and got a 404. Both outcomes fail, so this is not a real regression. But the type still suggests a projectless call is valid. Consider adding a JSDoc note on projectId (for example "Required. Calls without a project reject with invalid-argument"), or making it required in a later major version.
  • Nit: The error detail includes the upload id. That is fine for logs, and the existing warning test keeps filenames and bodies out of the log. Just confirm that onUnresolvableAttachment consumers do not show error.message to end users verbatim.
  • Nit: PR description. The "Not in this PR" section says Studio still calls a root /uploads alias. The root-cause section says that API was removed. If Studio's calls fail the same way, a linked follow-up issue would help make sure the projectless chat upload flow gets fixed end to end, not just made quieter here.

No blockers. Ensure the docs:api-reference:check gate passes in CI, because it was not run locally on the pinned Deno version.


Generated by Claude Code

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 66 371 KiB ✅ 0
src/react/components/Head.tsx 5 74 KiB ✅ 0
src/react/router/index.tsx 5 74 KiB ✅ 0
src/react/context/index.tsx 5 74 KiB ✅ 0
src/react/fonts/index.ts 6 81 KiB ✅ 0
src/react/components/ui/index.ts 111 720 KiB ✅ 0
src/react/components/ui/adapter/contract.ts 1 18 KiB ✅ 0
src/react/components/ui/icons/index.ts 3 17 KiB ✅ 0
src/chat/index.ts 305 2055 KiB ✅ 0
src/chat/ag-ui.ts 61 464 KiB ✅ 0
src/chat/protocol.ts 1 11 KiB ✅ 0
src/chat/types.ts 46 248 KiB ✅ 0
src/chat/message-prep.ts 68 519 KiB ✅ 0
src/markdown/index.ts 6 30 KiB ✅ 0
src/mdx/index.ts 2 2 KiB ✅ 0
src/agent/identity-contracts.ts 1 3 KiB ✅ 0
src/schemas/index.ts 43 222 KiB ✅ 0
src/platform/env.ts 5 55 KiB ✅ 0
src/workflow/claude-code/react/index.ts 9 91 KiB ✅ 0
src/events/index.ts 37 631 KiB ✅ 0
src/events/ag-ui/public.ts 36 624 KiB ✅ 0
src/run-events/index.ts 54 323 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: efcbb8ae5e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Parse the requested URLs and compare origin and pathname exactly instead
of a string prefix check, which CodeQL flags as incomplete URL substring
sanitization. The test still asserts no API request and no call to the
missing /uploads/{id}/url route.

Refs veryfront/veryfront-issue-inbox#4939

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 0708d9b623

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@kojiwakayama
kojiwakayama added this pull request to the merge queue Dec 4, 2026
@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2026

Copy link
Copy Markdown

Merged via the queue into main with commit 28c8c79 Dec 4, 2026
445 checks passed
@kojiwakayama
kojiwakayama deleted the fix/inbox-4939-projectless-upload-url branch December 4, 2026 15:57
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.

3 participants