Skip to content

feat(knowledge): 文件上传支持自定义元数据 - #6224

Open
Shinku-Chen wants to merge 2 commits into
Tencent:mainfrom
Shinku-Chen:feat/file-upload-custom-metadata
Open

Shinku-Chen wants to merge 2 commits into
Tencent:mainfrom
Shinku-Chen:feat/file-upload-custom-metadata

Conversation

@Shinku-Chen

@Shinku-Chen Shinku-Chen commented Nov 30, 2026 •

Copy link
Copy Markdown

Description

文件上传支持一个可选的 multipart 表单字段 custom_metadata。当请求同时携带 file、metadata 和 custom_metadata 时,服务在创建知识记录时一起保存两类元数据,然后提交解析任务。既有上传请求可继续省略新字段。

metadata 继续接收字符串值的 JSON 对象。新字段复用知识编辑接口的字段数量、长度和标量值校验。非法输入返回 HTTP 400,且不创建知识记录。Swagger 和 API 文档已补充请求示例。

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • 🎨 Refactor
  • ⚡ Performance improvement
  • 🧪 Test
  • 🔧 Configuration / Build / CI

Related Issue

Addresses #2090 的文件上传元数据部分。该 Issue 还包含知识库级元数据、检索过滤及文件搜索需求。

Testing

  • go test ./internal/handler ./internal/application/service -run 'TestCreateKnowledgeFromFile|Test.*CustomMetadata' -count=1 通过,覆盖同时保存两类元数据、省略字段的兼容性,以及非法字段拦截。
  • make docs 和 go test ./docs -count=1 通过。
  • go build ./... 通过。
  • golangci-lint run --new-from-rev=upstream/main ./... 通过(0 issues)。
  • 扩大到未筛选的 go test ./internal/types/... ./internal/handler ./internal/application/service -count=1 后,types 和 handler 通过,service 全包运行停在 TestDeleteAllSessionsReclaimsBeforeDirectoryCleanup,诊断后停止。该用例单独在本分支和上游基线上均通过。
  • 本地尚未部署运行针对异步解析的端到端验证。

Checklist

  • git diff --check upstream/main...HEAD passes
  • Changed source files are formatted
  • Targeted tests for the changed packages/components pass
  • Diff-scoped lint passes where applicable (for Go: golangci-lint run --new-from-rev=origin/main ./...)
  • Full-repository checks were run, or any unrelated/environment-dependent failures are documented above
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation (README, website-docs/, Swagger annotations, etc.)
  • Breaking changes are clearly called out in the description above(无破坏性变更)

Screenshots / Recordings

API 变更,无 UI 截图。

Assisted-by: Cindy (https://cindy.app)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant