Skip to content

🐛 fix: restore file access URL policy#15305

Merged
tjx666 merged 1 commit into
canaryfrom
fix/file-access-url-policy-reapply
May 28, 2026
Merged

🐛 fix: restore file access URL policy#15305
tjx666 merged 1 commit into
canaryfrom
fix/file-access-url-policy-reapply

Conversation

@tjx666

@tjx666 tjx666 commented May 28, 2026

Copy link
Copy Markdown
Member

💻 Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • ✅ test
  • 📝 docs
  • 🔨 chore

🔗 Related Issue

Fixes #15143

🔀 Description of Change

  • Restore file access URL resolution through FileService after the previous revert.
  • Keep /f/:id as a temporary presigned file proxy by adding a cached presigned preview URL API.
  • Pass file IDs through message file URL post-processing so server-side consumers can use stable /f/:id access URLs.
  • Clarify the S3 public URL fallback branch with an explicit public URL base guard.

🧪 How to Test

  • Tested locally
  • Added/updated tests
  • No tests needed
bunx vitest run --silent='passed-only' 'src/app/(backend)/f/[id]/route.test.ts' 'src/server/services/file/__tests__/index.test.ts' 'src/server/services/file/impls/s3.test.ts' 'src/server/routers/lambda/__tests__/file.test.ts' 'src/server/services/aiAgent/__tests__/execAgent.files.test.ts'\ncd packages/database && bunx vitest run --silent='passed-only' 'src/models/__tests__/messages/message.query.test.ts'\n```\n\n#### 📸 Screenshots / Videos\n\nN/A\n\n#### 📝 Additional Information\n\nThis re-applies the file access URL policy while keeping file proxy redirects temporary instead of switching `/f/:id` to public URLs when public S3 settings are present.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 28, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry @tjx666, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@dosubot dosubot Bot added the feature:files File upload and knowledge base label May 28, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4080af3f71

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

log('Cached presigned URL for file: %s (TTL: %ds)', id, PRESIGNED_URL_CACHE_TTL);
}
// Web: Generate a cached S3 presigned URL, normalizing legacy full S3 URLs.
const redirectUrl = await fileService.createCachedPreSignedUrlForPreview(file.url);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the proxy redirect's short expiry

When /f/:id is hit, this now omits the expiresIn argument, so the helper falls back to S3_PREVIEW_URL_EXPIRE_IN (7200 seconds by default in src/envs/file.ts) instead of the previous explicit 300-second proxy URL. Because this endpoint is public by file id and returns a direct S3 redirect, anyone who captures the Location header now gets much longer direct object access than the route previously allowed; pass the short proxy TTL through the cached helper to keep the old access policy.

Useful? React with 👍 / 👎.

@tjx666 tjx666 merged commit 234c87d into canary May 28, 2026
35 of 37 checks passed
@tjx666 tjx666 deleted the fix/file-access-url-policy-reapply branch May 28, 2026 14:51
Coooolfan pushed a commit to Coooolfan/lobehub that referenced this pull request Jun 1, 2026
@arvinxx arvinxx mentioned this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature:files File upload and knowledge base size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incomplete file preview src URL & Knowledge base chunks disappear on refresh

1 participant