fix: encode file keys in API paths#20
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes file-key operations proxy-safe by moving file keys out of URL path segments and into query parameters, while keeping the legacy path-based endpoints for compatibility. It updates both the FastAPI runtime and the Next.js web client, adds regression tests for tricky key shapes, and documents the new API contract.
Changes:
- Added
/files-by-key/*query-parameter routes (metadata/download/preview/delete) and refactored legacy/files/{key:path}routes to reuse shared handlers. - Updated the web API client to construct file-key requests via
?key=...and reject empty keys client-side. - Added backend + frontend regression tests for reserved characters, nested keys, and traversal-like inputs; updated the file-browser feature doc.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| services/api/tests/test_file_key_routes.py | Adds API-level coverage to ensure the new query-param routes accept reserved key shapes and reject invalid keys without touching the repo layer. |
| services/api/app/runtime/files.py | Introduces /files-by-key endpoints and refactors existing key routes to share response/exception handling helpers. |
| apps/web/src/lib/api-client.ts | Switches file-key operations to query-parameter requests and adds a client-side empty-key guard. |
| apps/web/src/lib/api-client.test.ts | Adds Vitest coverage to ensure the client constructs the correct paths and rejects empty keys before calling fetch. |
| docs/features/file-browser.md | Updates the feature contract and verification steps to reflect the new /files-by-key API. |
| apps/web/package.json | Adds a test script and Vitest dependency for the web package. |
| pnpm-lock.yaml | Lockfile updates to include Vitest/Vite dependency graph changes. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sophiecarreras
approved these changes
Jun 26, 2026
sophiecarreras
left a comment
Contributor
There was a problem hiding this comment.
✅ B2 standards verified: S3-compatible API, custom user agent, and standardized B2_* env vars all pass. Good to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/files-by-keyquery-parameter API routes for metadata, download, preview, and delete while keeping the legacy path routes available./files-by-keyis unavailable during rolling deploys.Linked issue
Closes #15
Tests run
git diff --checkpnpm lintpnpm --filter @vibe-coding-starter-kit/web testpnpm buildpnpm lint:apipnpm test:apipnpm check:structureFollow-up notes