fix: 修复oss读取etag时读取异常#7362
Open
shikaiwei1 wants to merge 1 commit into
Open
Conversation
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.
修复 @fastgpt-sdk/storage OSS 适配器 getObjectMetadata 读取 etag 错误
问题现象
使用阿里云 OSS(
STORAGE_VENDOR=oss)作为存储后端时,插件确认(/api/plugin/confirm)时报错:关键特征:
根本原因
sdk/storage/src/adapters/oss.adapter.ts的OssStorageAdapter.getObjectMetadata中,etag 读取位置错误:ali-ossSDK 的head()方法返回结构为:原代码
result.meta?.etag永远是undefined,导致下游FileMetaSchema.parse()(etag 要求string)校验失败。影响范围
result.ETag正确读取修复内容
从标准 HTTP 响应头
result.res.headers['etag']读取 etag,并去除 OSS 返回值自带的双引号(如"abc123"→abc123),避免下游使用 etag 拼接对象路径时引入非法字符:验证
tsc --noEmit类型检查通过GetObjectMetadataResult.etag类型为etag?: string,与undefined返回兼容