Skip to content

fix(shared): diagnose blocked 403 generation errors#297

Merged
Sun-sunshine06 merged 1 commit intomainfrom
fix/124-gateway-waf-diagnostic
May 3, 2026
Merged

fix(shared): diagnose blocked 403 generation errors#297
Sun-sunshine06 merged 1 commit intomainfrom
fix/124-gateway-waf-diagnostic

Conversation

@Sun-sunshine06
Copy link
Copy Markdown
Collaborator

Summary

  • classify 403 generation errors that explicitly say the request was blocked as gateway/reverse-proxy blocks
  • keep plain 403 responses mapped to the existing API key/auth diagnostic
  • add localized diagnostic copy and report context coverage

Fixes #124

Validation

  • pnpm exec biome check packages/shared/src/diagnostics.ts packages/shared/src/diagnostics.test.ts apps/desktop/src/renderer/src/store.test.ts packages/i18n/src/locales/en.json packages/i18n/src/locales/es.json packages/i18n/src/locales/pt-BR.json packages/i18n/src/locales/zh-CN.json .changeset/gateway-waf-blocked-diagnostic.md
  • pnpm --dir packages/shared exec vitest run src/diagnostics.test.ts
  • pnpm --dir apps/desktop exec vitest run src/renderer/src/store.test.ts
  • pnpm --dir apps/desktop typecheck
  • pnpm typecheck
  • pnpm --dir apps/desktop test

@github-actions github-actions Bot added docs Documentation area:desktop apps/desktop (Electron shell, renderer) labels May 3, 2026
Copy link
Copy Markdown
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.

Review mode: initial

Findings

No blockers or major issues found. The PR is well-structured and addresses the stated problem.

  • The new looksLikeGatewayWafBlock function correctly identifies gateway/WAF blocked messages using common keywords. The integration in diagnoseGenerateFailure properly prioritises the blocked check before falling through to the generic 403 → keyInvalid path.
  • Unit tests in diagnostics.test.ts and integration tests in store.test.ts cover the new classification. The test verifies toast description, display_message, and diagnostic_category.
  • Locale strings are added for all four supported languages (en, es, pt-BR, zh-CN).
  • A changeset is included with appropriate patch bumps for @open-codesign/shared, @open-codesign/desktop, and @open-codesign/i18n.

Minor:

  • The store test assertion (toContain('gateway or reverse proxy blocked')) is brittle if the locale description wording changes. Consider checking the i18n key or a more stable substring. Not a merge blocker.

Regarding the linked issue #124: The PR body says "Fixes #124". The issue content was not accessible during this review run, so the completeness of the fix cannot be fully verified from the issue's acceptance criteria. However, the diff aligns with the PR title and description — classifying 403 blocked generation errors as gateway/WAF blocks. If the issue has additional requirements (e.g., handling other blocked response patterns or UI changes), they are not reflected here. Consider confirming with the author or updating the issue reference to Refs #124 if this is a partial implementation.

Summary

The PR adds a new diagnostic category gateway-waf-blocked for 403 generation errors that include a blocked-request message. This improves the user experience by showing a more specific cause and suggested fix (check proxy allowlist/headers) instead of a generic invalid API key message. All code paths are tested, and translations are provided. Changes are localized and backward-compatible.

Open-CoDesign Bot

@Sun-sunshine06 Sun-sunshine06 merged commit 418e5a8 into main May 3, 2026
6 checks passed
@Sun-sunshine06 Sun-sunshine06 deleted the fix/124-gateway-waf-diagnostic branch May 3, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:desktop apps/desktop (Electron shell, renderer) docs Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

正常对话时报 403 错误:Error invoking remote method 'codesign:v1:generate'

1 participant