Skip to content

fix(knowledge): map invalid path errors to 400 KNOWLEDGE_PATH_INVALID (#909) - #1069

Closed
Jay0130-a wants to merge 1 commit into
TencentCloud:developfrom
Jay0130-a:fix/knowledge-path-400-909
Closed

Jay0130-a wants to merge 1 commit into
TencentCloud:developfrom
Jay0130-a:fix/knowledge-path-400-909

Conversation

@Jay0130-a

Copy link
Copy Markdown

背景

Closes #909。POST /api/knowledge-bases/{kb_id}/folders 等接口对调用方传入的非法路径(含 ..、空/根目录如 .、/)返回 500 INTERNAL_ERROR 并打堆栈,应为 400。

改动

  • 新增错误码 KNOWLEDGE_PATH_INVALID(HTTP 400),补 en/zh 文案。
  • _map_knowledge_error 将 invalid knowledge document path / invalid knowledge folder path 映射到新错误码,不再落兜底分支。

测试计划

  • 新增参数化测试覆盖两条消息 -> 400;原有 unclassified->500 测试仍通过。
  • ruff check / ruff format 干净。

…ALID (TencentCloud#909)

Path validation ValueErrors from normalize_kb_path/ensure_folder (e.g. '..'
segments, empty/root paths) fell through to the unhandled-error branch and
returned 500 with a stack trace. These are caller input errors, so map them
to a new 400 error code KNOWLEDGE_PATH_INVALID with en/zh messages.
@Jay0130-a
Jay0130-a force-pushed the fix/knowledge-path-400-909 branch from 918d42c to 095cfa7 Compare September 23, 2026 15:12
@jubaoliang

Copy link
Copy Markdown
Collaborator

关闭:与 #910 同修非法知识库路径落到 500(#909)。

#1069 只补了后端 ErrorCode / i18n,缺 dashboard apiErrors,会撞 test_dashboard_api_errors_match_backend。#910 四套文案 + create_folder 用例更完整。请以 #910 为准。

@jubaoliang jubaoliang closed this Sep 24, 2026
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.

2 participants