Repository navigation
fix(agent): stop asking the API for a projectless upload URL it does not serve - #5678
Conversation
…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>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Score: 86/100. A small, well-scoped fix. It stops a request that could never succeed and leaves the existing degrade path unchanged.
No blockers. Ensure the Generated by Claude Code |
📦 Client bundle boundary
A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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 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>
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|



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 warningHosted chat attachment unreadable; continuing without it, after a request that could never succeed.Refs veryfront/veryfront-issue-inbox#4939
Root cause
createRuntimeUploadUrlinsrc/agent/runtime/upload-url-client.tsfell back to a root/uploads/{id}/urlpath when the run had no project. That path is a leftover of a contract the API retired:4ccb3b5e68("Remove deprecated root uploads REST API", with the directive not to reintroduce root upload aliases without a migration contract for project ownership).8382857e38("project-scoped only").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, andexternal-storage/import.ts, which refuses without a project).upload.project_idis 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
getRuntimeUploadUrlrejects withinvalid-argumentbefore any request when it has noprojectId(undefined,nullor 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, andonUnresolvableAttachmentlogs the warning.RuntimeUploadUrlOptions.projectIdstays 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 withinvalid-argumentand sends no request. This replaces the test that pinned the root/uploads/{id}/urlcall.src/agent/hosted/chat-preparation.test.ts:prepareHostedChatRuntimeMessageswithprojectId: nullsends nothing to the API, reports the upload once throughonUnresolvableAttachment, 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 --checkon the changed files,deno check src/agent/index.tsNot 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
GET /uploads/{upload_id}/urlinsrc/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-apimainthe surface still admits the whole/uploadsprefix.studio/lib/chat/uploadChatDataFiles.tsandserver/mcp/tools/media/displayMediaLogic.tsin veryfront-studio still call the root/uploadsalias 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.🤖 Generated with Claude Code