Repository navigation
Fix #25: give feedback failures their own error wording - #36
Open
xiaoyao-666-coder wants to merge 2 commits into
Open
xiaoyao-666-coder wants to merge 2 commits into
xiaoyao-666-coder wants to merge 2 commits into
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.
问题
反馈失败(例如 422,服务端返回
{"detail": ...})时,UI 把formatHttpError的通用文案显示出来,文案写的是“请检查问题描述并重试”——那是聊天输入框的校验文案,跟反馈半点关系没有。根因是sendFeedback的失败分支复用了聊天场景的错误处理,文案与场景完全错位。修复
formatHttpError没动:它在会话初始化和聊天发送两处服务于提问场景,一字未改。反馈单独走新纯模块frontend/src/feedback-error.ts的formatFeedbackError(沿用项目已有的场景专属格式化器模式,如formatAuthError),App.tsx里sendFeedback的 catch 只换了这一处调用(5 行增、1 行删)。401 提前回登录页的逻辑原样保留。formatFeedbackError({status, detail}),detail是ensureResponseOk已解析好的服务端 detail,含 FastAPI 数组型 detail 拼成的 msg 串):/api/feedback的真实 detail);无 detail → 按状态给反馈专属通用文案,如 422 是“反馈内容未通过校验,请重试。”、404 是“当前会话已过期,请新建整理后重试。”;SessionBackendError的str(exc),可能含内网地址/连接信息),一律用“整理服务暂时不可用,请稍后重试。”;验证
npm test32 pass / 0 fail(基线 10 + 新增 22),npm run build正常。覆盖:422 有/无 detail、FastAPI 校验 detail 原样展示、404 有/无 detail、5xx 不泄露后端 detail、429/426、401 兜底、空白 detail、超长截断、未知状态,以及一个横扫断言——12 种状态×detail 组合的输出里都不含“问题描述”/“2000”。MEDGUIDE_MODE=test python -m pytest -q backend/tests521 passed(基线,无后端改动)。App.tsx只改了 import 和sendFeedback的 catch;formatHttpError本身及其两个聊天调用点未动,聊天发送的错误文案不受影响(diff 审查确认)。已知遗留
Closes #25