🐛 修复带路径前缀的 S3 端点(如 Supabase)同步失败 - #1729
Open
CodFrm wants to merge 1 commit into
Open
Conversation
S3Client 只取 endpoint 的协议/主机/端口,丢掉了 endpoint 自带的路径前缀, 请求与签名的 canonical URI 都落在服务根路径上,Supabase 的 https://<ref>.storage.supabase.co/storage/v1/s3 因此在验证阶段返回 404 NotFound。 统一由 getResourcePath 生成请求路径与 canonical URI,保留 endpoint 路径前缀。 close #1723
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.
Checklist / 检查清单
Description / 描述
close #1723
S3Client解析 endpoint 后只使用protocol/hostname/port,丢弃了 endpoint 自带的路径前缀:buildUrl()与签名用的getCanonicalUri()都从/开始拼 bucket 与 key。对于把 S3 API 挂在子路径上的服务(Supabase Storage 的https://<ref>.storage.supabase.co/storage/v1/s3),请求实际打到了服务根路径https://<ref>.storage.supabase.co/<bucket>,服务端返回 404,verify()将其映射为NotFound—— 即 issue 中「云同步账号信息验证失败: NotFound」。MinIO、Wasabi、AWS 等端点没有路径前缀,因此不受影响,这解释了「其他支持 S3 的系统可以正常同步」。修复:把请求 URL 路径与签名的 canonical URI 合并为单一的
getResourcePath(),统一带上 endpoint 的路径前缀(前缀来自URL.pathname,已完成百分号编码,不再重复编码);getEndpointUrl()同样返回含前缀的地址,使getDirUrl()不再给出错误链接。两者共用同一实现,也顺带消除了原先「URL 用未编码 bucket、签名用编码 bucket」的不一致。验证:
packages/filesystem/s3/client.test.ts)覆盖带前缀 endpoint 的 path-style / virtual-hosted URL、末尾斜杠、以及签名 canonical URI。修复前 5 个全部失败,修复后通过。其中「相同绝对路径必须产出相同签名」的用例可挡住「URL 带前缀但签名不带」的半修复。ap-northeast-1)跑通完整链路:verify→create/write→list→read→delete;修复前同一配置复现Error: NotFound。测试对象已清理。pnpm vitest run --no-coverage packages/filesystem179 passed;pnpm run typecheck、prettier --check、eslint均通过。Screenshots / 截图
N/A —— 无 UI 变更。