Skip to content

fix(proxy): persist Fake 200 error detail to DB/Redis and display in dashboard#814

Merged
ding113 merged 2 commits intodevfrom
fix/fake200-error-detail-persistence
Feb 22, 2026
Merged

fix(proxy): persist Fake 200 error detail to DB/Redis and display in dashboard#814
ding113 merged 2 commits intodevfrom
fix/fake200-error-detail-persistence

Conversation

@ding113
Copy link
Owner

@ding113 ding113 commented Feb 22, 2026

Summary

When upstream returns HTTP 200 but the JSON body contains error.message (Fake 200 detection code FAKE_200_JSON_ERROR_MESSAGE_NON_EMPTY), the actual error text from detected.detail was only logged via logger.warn and then discarded. Only detected.code was persisted.

This caused two UX issues:

  1. LogicTraceTab: providerChain[].errorMessage showed the raw code "FAKE_200_JSON_ERROR_MESSAGE_NON_EMPTY" instead of the actual upstream error (e.g. "Invalid API key")
  2. SummaryTab: errorMessage in DB was just the code, losing the actual cause

Related Issues & PRs:

Changes

response-handler.ts

  • DB/Redis persistence (line 188): errorMessage now stores "CODE: detail" format (e.g. "FAKE_200_JSON_ERROR_MESSAGE_NON_EMPTY: Invalid API key") so the actual error is persisted
  • Provider chain (line 333): addProviderToChain now uses detected.detail ?? detected.code, so LogicTraceTab shows the actual error text

SummaryTab.tsx

  • Extract the code prefix from the new "CODE: detail" format before passing to getFake200ReasonKey() for correct i18n lookup
  • isFake200PostStreamFailure check still works since the new format still starts with "FAKE_200_"

Data Flow After Fix

Stream ends -> allContent collected
  -> detectUpstreamErrorFromSseOrJsonText(allContent)
  -> detected = { code: "FAKE_200_...", detail: "Invalid API key" }
  -> errorMessage = "FAKE_200_...: Invalid API key"        [DB + Redis]
  -> addProviderToChain({ errorMessage: "Invalid API key" }) [LogicTraceTab]

Breaking Changes

None. This is a UX improvement that changes the internal format of errorMessage persistence but maintains backward compatibility:

  • Old format: "FAKE_200_JSON_ERROR_MESSAGE_NON_EMPTY"
  • New format: "FAKE_200_JSON_ERROR_MESSAGE_NON_EMPTY: Invalid API key"
  • The startsWith("FAKE_200_") check in SummaryTab.tsx continues to work correctly

Testing

Automated Tests

  • bun run typecheck - passed
  • bun run lint - passed (no new warnings)
  • bun run test - 348 files, 3234 tests passed

Manual Testing

  • Send request through provider returning {"error":{"message":"some error"}} with HTTP 200, verify SummaryTab and LogicTraceTab display correctly

Checklist

  • Code follows project conventions
  • Self-review completed
  • Tests pass locally
  • No breaking changes

Description enhanced with related issue/PR links

Greptile Summary

Enhanced fake 200 error handling by persisting the actual upstream error detail (e.g., "Invalid API key") alongside the detection code in a "CODE: detail" format, improving visibility in both the dashboard summary and provider chain logs.

  • Updated response-handler.ts to persist errors as "FAKE_200_JSON_ERROR_MESSAGE_NON_EMPTY: Invalid API key" instead of just "FAKE_200_JSON_ERROR_MESSAGE_NON_EMPTY"
  • Modified SummaryTab.tsx to extract the code prefix for i18n lookup while displaying the full detail
  • Updated provider-chain-popover.tsx to handle the new format in fake 200 detection and display logic

Issues Found:

  • Line 550 in provider-chain-popover.tsx lacks optional chaining and may cause runtime errors if item.errorMessage is undefined or doesn't contain ": "

Confidence Score: 3/5

  • This PR improves UX but contains a logic bug that could cause runtime errors
  • The implementation correctly updates the error format across the codebase, but line 550 in provider-chain-popover.tsx has inconsistent null-safety handling compared to line 138, which could cause crashes when processing provider chain items
  • Pay close attention to src/app/[locale]/dashboard/logs/_components/provider-chain-popover.tsx - fix the optional chaining issue on line 550

Important Files Changed

Filename Overview
src/app/v1/_lib/proxy/response-handler.ts Updated fake 200 error persistence to include detail text in "CODE: detail" format for both DB/Redis (line 188) and provider chain (line 333)
src/app/[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx Extracts code prefix from new "CODE: detail" format before i18n lookup, maintains backward compatibility with old format
src/app/[locale]/dashboard/logs/_components/provider-chain-popover.tsx Extracts code prefix from "CODE: detail" format in two locations (line 138, 550) but has potential runtime error on line 550

Last reviewed commit: 13563c9

…dashboard

When upstream returns HTTP 200 with an error body (Fake 200), the detected
error detail was only logged but not persisted. This caused the dashboard to
show the raw detection code (e.g. "FAKE_200_JSON_ERROR_MESSAGE_NON_EMPTY")
instead of the actual upstream error text (e.g. "Invalid API key").

- Store "CODE: detail" in errorMessage for DB/Redis persistence
- Show actual detail (not code) in LogicTraceTab provider chain
- Extract code prefix in SummaryTab for correct i18n lookup
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ding113, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a user experience issue where detailed error messages for "Fake 200" responses were not being properly stored or displayed in the dashboard. Previously, only a generic error code was visible, hindering effective diagnosis. The changes ensure that specific upstream error details are now consistently persisted and correctly presented in both the LogicTraceTab and SummaryTab, significantly improving the clarity and debuggability of error reporting.

Highlights

  • Error Detail Persistence: The full FAKE_200 error detail, such as "Invalid API key", is now persisted to the database and Redis, instead of only the generic error code.
  • Improved Dashboard Display: The LogicTraceTab now displays the actual upstream error message, and the SummaryTab correctly parses and shows these detailed errors, enhancing user experience and debuggability.
  • Standardized Error Format: An "CODE: detail" format has been implemented for errorMessage storage, ensuring that both the error code and its specific detail are retained.
Changelog
  • src/app/[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx
    • Introduced fake200Code extraction to correctly retrieve the error code from the new "CODE: detail" format for internationalization (i18n) lookup.
    • Updated fake200Reason logic to utilize the newly extracted fake200Code.
  • src/app/v1/_lib/proxy/response-handler.ts
    • Modified errorMessage assignment to store detected.detail alongside detected.code in the format "CODE: detail" when detected.detail is available.
    • Updated addProviderToChain to pass detected.detail (if present) as errorMessage for improved display in the LogicTraceTab.
Activity
  • bun run typecheck passed.
  • bun run lint passed with no new warnings.
  • bun run test passed for 348 files and 3234 tests.
  • Manual testing is pending to verify correct display in SummaryTab and LogicTraceTab for FAKE_200 errors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Feb 22, 2026

📝 Walkthrough

Walkthrough

更新了 FAKE_200 相关错误消息的提取与传递:在响应处理器中将上游错误构造成 "code: detail" 格式;在多个 UI 组件中改为使用从该字符串提取的 code(冒号前缀)作为 fake200 的原因/显示键。

Changes

Cohort / File(s) Summary
摘要选项卡(错误详情)
src/app/[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx
新增派生变量 fake200Code(从 errorMessage 中取冒号前的 code),并将 fake200Reason 的计算改为基于 fake200Code。保留现有的 isFake200PostStreamFailure 门控行为。
响应处理器(上游错误信息构造)
src/app/v1/_lib/proxy/response-handler.ts
当检测到上游错误时,将 errorMessage 构造成 code: detail(若 detail 存在)或仅 code,并在原有 fake-200 检测与非 200 结束路径中使用此格式。控制流未改动。
Provider 链展示(Fake200 显示值)
src/app/[locale]/dashboard/logs/_components/provider-chain-popover.tsx
对从链中识别的 FAKE_200_* 字符串取冒号前缀作为 fake200CodeForDisplay,并将该前缀用于本地化键和 tooltip/行内显示,而不是使用完整的 errorMessage 字符串。其余逻辑保持不变。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确反映了主要改动:将Fake 200错误详情持久化到DB/Redis并在仪表板中显示,这正是本PR的核心目标。
Linked Issues check ✅ Passed PR成功地解决了#749中报告的问题:现在能检测并持久化HTTP 200响应中的上游错误详情,并在仪表板中正确显示,改善了用户体验。
Out of Scope Changes check ✅ Passed 所有改动都直接服务于PR目标:response-handler.ts处理持久化格式、SummaryTab.tsx提取代码前缀进行i18n查询、provider-chain-popover.tsx提取前缀用于显示。
Description check ✅ Passed PR描述清晰地说明了问题、解决方案和数据流变化,与代码变更高度相关。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/fake200-error-detail-persistence

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added bug Something isn't working area:UI area:Error Rule labels Feb 22, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses the issue of losing valuable error details for 'Fake 200' responses. The changes ensure that the full error detail is persisted to the database and Redis by formatting the main error message as <code>: <detail>. For a cleaner user experience in the LogicTraceTab, the provider chain error message is updated to show just the error detail. The corresponding frontend change in SummaryTab.tsx is well-implemented, correctly parsing the new error message format while maintaining backward compatibility. The code is clear, and the solution is robust. I have no further suggestions.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

statusCode: effectiveStatusCode,
statusCodeInferred,
errorMessage: detected.code,
errorMessage: detected.detail ?? detected.code,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaks fake 200 UI in provider-chain-popover

This change sets the provider chain's errorMessage to detected.detail ?? detected.code. When detected.detail is present (e.g., "Invalid API key"), the value no longer starts with "FAKE_200_".

However, provider-chain-popover.tsx relies on item.errorMessage.startsWith("FAKE_200_") in three places (lines 131-136, 542-553) to detect fake 200 errors and render warning banners. After this change, those checks will evaluate to false for any fake 200 with a detail string, silently breaking:

  1. hasFake200PostStreamFailure (line 131) — the fake 200 warning section won't render
  2. fake200CodeForDisplay (line 134) — the reason text won't render
  3. Per-item fake 200 indicator (line 542) — individual chain items won't show the indicator

Additionally, there's an inconsistency within this file: at line 281, the !streamEndedNormally path passes errorMessage (which uses the "CODE: detail" format from line 188 and starts with FAKE_200_), while this path passes just the detail text. The popover will behave differently depending on which code path was taken.

Consider either:

  • Using a consistent format for both DB and chain (e.g., "CODE: detail" everywhere, and extracting the code in the UI as done in SummaryTab.tsx)
  • Updating provider-chain-popover.tsx to handle the new format
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/app/v1/_lib/proxy/response-handler.ts
Line: 333

Comment:
**Breaks fake 200 UI in provider-chain-popover**

This change sets the provider chain's `errorMessage` to `detected.detail ?? detected.code`. When `detected.detail` is present (e.g., `"Invalid API key"`), the value no longer starts with `"FAKE_200_"`.

However, `provider-chain-popover.tsx` relies on `item.errorMessage.startsWith("FAKE_200_")` in three places (lines 131-136, 542-553) to detect fake 200 errors and render warning banners. After this change, those checks will evaluate to `false` for any fake 200 with a detail string, silently breaking:

1. `hasFake200PostStreamFailure` (line 131) — the fake 200 warning section won't render
2. `fake200CodeForDisplay` (line 134) — the reason text won't render
3. Per-item fake 200 indicator (line 542) — individual chain items won't show the indicator

Additionally, there's an inconsistency within this file: at line 281, the `!streamEndedNormally` path passes `errorMessage` (which uses the `"CODE: detail"` format from line 188 and starts with `FAKE_200_`), while this path passes just the detail text. The popover will behave differently depending on which code path was taken.

Consider either:
- Using a consistent format for both DB and chain (e.g., `"CODE: detail"` everywhere, and extracting the code in the UI as done in `SummaryTab.tsx`)
- Updating `provider-chain-popover.tsx` to handle the new format

How can I resolve this? If you propose a fix, please make it concise.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/app/[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx (1)

72-73: fake200Code 的 else 分支应返回 null 而非 errorMessage

该变量仅在 isFake200PostStreamFailure && fake200Code 条件下使用(第 75 行),当 isFake200PostStreamFailurefalse 时其值永远不会被读取。当前 else 分支返回 errorMessage 会导致变量名与内容不符(持有任意错误消息),并存在冗余的 && errorMessage 守卫(isFake200PostStreamFailure 已隐含 errorMessage 为非空字符串)。

♻️ 建议的简化方式
-  const fake200Code =
-    isFake200PostStreamFailure && errorMessage ? errorMessage.split(": ")[0] : errorMessage;
+  const fake200Code = isFake200PostStreamFailure ? errorMessage!.split(": ")[0] : null;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/app/`[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx
around lines 72 - 73, The variable fake200Code is misnamed because its else
branch returns errorMessage; change the initialization of fake200Code so that it
returns the parsed code (errorMessage.split(": ")[0]) when
isFake200PostStreamFailure is true and otherwise returns null, and remove the
redundant "&& errorMessage" guard when checking isFake200PostStreamFailure since
that condition already implies a non-empty errorMessage; update usages that
check "isFake200PostStreamFailure && fake200Code" to rely on fake200Code being
null when not applicable.
src/app/v1/_lib/proxy/response-handler.ts (1)

188-188: "CODE: detail" 格式仅应用于 fake-200 路径,与非 200 状态码路径不一致

第 188 行的修改正确地将 detected.detail 持久化到 DB/Redis,但同一函数内的非 200 状态码路径(第 196-203 行)仍仅使用 detected.code,不包含 detail

// 第 199 行(未改动)
errorMessage = detected.isError ? detected.code : `HTTP ${upstreamStatusCode}`;

handleNonStream 中的类似路径(第 855 行)同样未做更新。如果希望所有错误路径均在 Dashboard 中展示详细信息,建议对这些路径做相同处理。

此外,AI 摘要称该变更"同时影响……流自然结束后的非 200 处理路径",但第 199 行并未标注为已修改(无 ~)— AI 摘要与实际代码不符。

♻️ 可选:对非 200 SSE 路径应用相同的格式
-  errorMessage = detected.isError ? detected.code : `HTTP ${upstreamStatusCode}`;
+  errorMessage = detected.isError
+    ? (detected.detail ? `${detected.code}: ${detected.detail}` : detected.code)
+    : `HTTP ${upstreamStatusCode}`;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/v1/_lib/proxy/response-handler.ts` at line 188, The non-200 error
paths still construct errorMessage using only detected.code (e.g., the
assignment using detected.isError ? detected.code : `HTTP ${upstreamStatusCode}`
and the equivalent branch inside handleNonStream), so update those assignments
to include detected.detail when present using the same format as the fake-200
path (i.e., use detected.detail ? `${detected.code}: ${detected.detail}` :
detected.code for detected errors, and for non-detected errors keep the existing
`HTTP ${upstreamStatusCode}` behavior), and also correct the AI summary/comment
that claims the non-200 SSE path was modified so it accurately reflects which
lines/functions changed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@src/app/`[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx:
- Around line 72-73: The variable fake200Code is misnamed because its else
branch returns errorMessage; change the initialization of fake200Code so that it
returns the parsed code (errorMessage.split(": ")[0]) when
isFake200PostStreamFailure is true and otherwise returns null, and remove the
redundant "&& errorMessage" guard when checking isFake200PostStreamFailure since
that condition already implies a non-empty errorMessage; update usages that
check "isFake200PostStreamFailure && fake200Code" to rely on fake200Code being
null when not applicable.

In `@src/app/v1/_lib/proxy/response-handler.ts`:
- Line 188: The non-200 error paths still construct errorMessage using only
detected.code (e.g., the assignment using detected.isError ? detected.code :
`HTTP ${upstreamStatusCode}` and the equivalent branch inside handleNonStream),
so update those assignments to include detected.detail when present using the
same format as the fake-200 path (i.e., use detected.detail ? `${detected.code}:
${detected.detail}` : detected.code for detected errors, and for non-detected
errors keep the existing `HTTP ${upstreamStatusCode}` behavior), and also
correct the AI summary/comment that claims the non-200 SSE path was modified so
it accurately reflects which lines/functions changed.

@github-actions github-actions bot added the size/XS Extra Small PR (< 50 lines) label Feb 22, 2026
…andle in popover

The previous commit used detected.detail ?? detected.code for the provider
chain errorMessage, which stripped the FAKE_200_ prefix and broke the
startsWith("FAKE_200_") checks in provider-chain-popover.tsx.

- Use "CODE: detail" format in addProviderToChain (consistent with DB)
- Extract code prefix via split(": ")[0] in popover for i18n lookup
- Extract code prefix in fake200CodeForDisplay for warning banner
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

reason: t(
getFake200ReasonKey(
item.errorMessage,
item.errorMessage.split(": ")[0],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

potential runtime error if item.errorMessage doesn't contain ": "

The code assumes all fake 200 errors have the new format, but old errors or errors without detail will cause .split(": ")[0] to return the full string. Line 138 handles this correctly by using optional chaining (?.errorMessage?.split), but this line doesn't.

Suggested change
item.errorMessage.split(": ")[0],
item.errorMessage?.split(": ")[0] ?? item.errorMessage,
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/app/[locale]/dashboard/logs/_components/provider-chain-popover.tsx
Line: 550

Comment:
potential runtime error if `item.errorMessage` doesn't contain ": "

The code assumes all fake 200 errors have the new format, but old errors or errors without detail will cause `.split(": ")[0]` to return the full string. Line 138 handles this correctly by using optional chaining (`?.errorMessage?.split`), but this line doesn't.

```suggestion
                                  item.errorMessage?.split(": ")[0] ?? item.errorMessage,
```

How can I resolve this? If you propose a fix, please make it concise.

@ding113 ding113 merged commit 38f8537 into dev Feb 22, 2026
10 of 12 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Claude Code Hub Roadmap Feb 22, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

This PR addresses a legitimate UX issue where Fake 200 error details were being discarded. The implementation correctly persists the upstream error detail alongside the detection code in a "CODE: detail" format, improving visibility in both the dashboard summary and provider chain logs.

PR Size: XS

  • Lines changed: 20 (12 additions, 8 deletions)
  • Files changed: 3

Issues Found

Category Critical High Medium Low
Logic/Bugs 0 0 0 0
Security 0 0 0 0
Error Handling 0 0 0 0
Types 0 0 0 0
Comments/Docs 0 0 0 0
Tests 0 0 0 0
Simplification 0 0 0 0

No significant issues identified.

Review Coverage

  • Logic and correctness - Clean. The new format "CODE: detail" correctly maintains backward compatibility via startsWith(\"FAKE_200_\") checks.
  • Security (OWASP Top 10) - Clean. Error details are already sanitized via sanitizeErrorTextForDetail() in upstream-error-detection.ts before being persisted.
  • Error handling - Clean. Proper null-safety with optional chaining (item.errorMessage?.split(\"\")[0]) handles both new and old format gracefully.
  • Type safety - Clean. No unsafe any usage; leverages existing TypeScript types.
  • Documentation accuracy - Clean. No misleading comments or documentation drift.
  • Test coverage - Adequate. Existing tests in error-details-dialog.test.tsx and provider-chain-popover.test.tsx verify Fake 200 detection behavior.
  • Code clarity - Good. The split pattern is straightforward and the data flow is clear.

Notable Implementation Details

  1. response-handler.ts: Now persists \"\${detected.code}: \${detected.detail}\" when detail exists, ensuring the actual upstream error is stored in DB/Redis.

  2. SummaryTab.tsx: Extracts the code prefix using errorMessage.split(\": \")[0] for i18n lookup while preserving backward compatibility.

  3. provider-chain-popover.tsx: Uses optional chaining (item.errorMessage?.split(\": \")[0]) for safe extraction, handling cases where errorMessage might be undefined.


Automated review by Claude AI

specialSettings && specialSettings.length > 0 ? JSON.stringify(specialSettings, null, 2) : null;
const isFake200PostStreamFailure =
typeof errorMessage === "string" && errorMessage.startsWith("FAKE_200_");
const fake200Code =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] [TEST-EDGE-CASE] No unit coverage for new "FAKE_200_*: detail" parsing

Why this is a problem: New logic now relies on errorMessage.split(": ")[0] to recover the FAKE_200 code for i18n lookups:

  • src/app/[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx:72-77
  • src/app/[locale]/dashboard/logs/_components/provider-chain-popover.tsx:134-138 and :549-552

Existing UI tests only exercise the raw code format (no ": detail" suffix), so a delimiter/format regression will slip:

  • src/app/[locale]/dashboard/logs/_components/error-details-dialog.test.tsx:400-414
  • src/app/[locale]/dashboard/logs/_components/provider-chain-popover.test.tsx:274-291

This conflicts with CLAUDE.md:

  • 2. **Test Coverage** - All new features must have unit test coverage of at least 80%

Suggested fix: Add/extend tests to cover the new "CODE: detail" format.

// src/app/[locale]/dashboard/logs/_components/error-details-dialog.test.tsx
test("renders fake-200 detected reason when errorMessage uses CODE: detail", () => {
  const html = renderWithIntl(
    <ErrorDetailsDialog
      externalOpen
      statusCode={502}
      errorMessage={"FAKE_200_JSON_ERROR_MESSAGE_NON_EMPTY: Invalid API key"}
      providerChain={null}
      sessionId={null}
    />
  );

  expect(html).toContain("Detected reason: JSON has non-empty error.message");
});
// src/app/[locale]/dashboard/logs/_components/provider-chain-popover.test.tsx
test("renders fake-200 detected reason when chain errorMessage uses CODE: detail", () => {
  const html = renderWithIntl(
    <ProviderChainPopover
      chain={[
        {
          id: 1,
          name: "p1",
          reason: "retry_failed",
          statusCode: 502,
          errorMessage: "FAKE_200_JSON_ERROR_MESSAGE_NON_EMPTY: Invalid API key",
        },
      ]}
      finalProvider="p1"
    />
  );

  expect(html).toContain("Detected reason: JSON has non-empty error.message");
});

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

This PR changes fake-200 error persistence to store CODE: detail and updates dashboard components to split the code prefix for i18n lookups. The behavior change is reasonable, but the new parsing path is not covered by existing UI unit tests, increasing regression risk if the delimiter/format changes.

PR Size: XS

  • Lines changed: 20
  • Files changed: 3

Issues Found

Category Critical High Medium Low
Logic/Bugs 0 0 0 0
Security 0 0 0 0
Error Handling 0 0 0 0
Types 0 0 0 0
Comments/Docs 0 0 0 0
Tests 0 0 1 0
Simplification 0 0 0 0

Critical Issues (Must Fix)

None.

High Priority Issues (Should Fix)

  • src/app/[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx:72 and src/app/[locale]/dashboard/logs/_components/provider-chain-popover.tsx:134 lack unit coverage for the new "FAKE_200_*: detail" parsing (confidence 85).

Review Coverage

  • Logic and correctness
  • Security (OWASP Top 10)
  • Error handling
  • Type safety
  • Documentation accuracy
  • Test coverage
  • Code clarity

Automated review by Codex AI

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Identified PR #814 and updated stats: +12/-8 (20 lines), 3 files; applied/confirmed label size/XS.
  • Posted 1 inline review comment on src/app/[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx calling out missing unit coverage for the new "FAKE_200_*: detail" parsing (with concrete test snippets for error-details-dialog.test.tsx and provider-chain-popover.test.tsx).
  • Submitted the required “Code Review Summary” via gh pr review.

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

Labels

area:Error Rule area:UI bug Something isn't working size/XS Extra Small PR (< 50 lines)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant