Skip to content

🐛 fix: handle runtime request errors#15478

Merged
tjx666 merged 7 commits into
canaryfrom
fix/output-json-runtime-errors
Jun 5, 2026
Merged

🐛 fix: handle runtime request errors#15478
tjx666 merged 7 commits into
canaryfrom
fix/output-json-runtime-errors

Conversation

@tjx666

@tjx666 tjx666 commented Jun 4, 2026

Copy link
Copy Markdown
Member

💻 Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • ✅ test
  • 📝 docs
  • 🔨 chore

🔗 Related Issue

N/A

🔀 Description of Change

  • Convert known model-runtime errors thrown by aiChat.outputJSON into native TRPCError instances so expected provider/config/quota/request failures no longer surface as generic 500 errors.
  • Reuse the shared runtime error spec and tRPC's existing status-code mapping instead of maintaining a custom mapping in the router.
  • Avoid treating runtime provider auth failures such as InvalidProviderAPIKey as LobeHub session-expired errors in responseMeta.
  • Pass OIDC request bodies through as a readable Node stream instead of attaching a pre-parsed body object.

🧪 How to Test

  • Tested locally
  • Added/updated tests
  • No tests needed
bunx vitest run --silent='passed-only' src/libs/oidc-provider/http-adapter.test.ts src/libs/trpc/utils/responseMeta.test.ts src/server/routers/lambda/__tests__/aiChat.test.ts
vscode-cli get-diagnostics --workspace /Users/tj/code/lobehub-cloud

📸 Screenshots / Videos

N/A

📝 Additional Information

The HTTP response status is still produced by tRPC from TRPCError.code; this PR only normalizes model-runtime errors before they reach tRPC's default INTERNAL_SERVER_ERROR wrapper.

The OIDC adapter test now also feeds a /oidc/token form body through oidc-provider's own urlencoded parser to verify grant_type, code, client_id, redirect_uri, and code_verifier remain parseable from the Node readable stream.

@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Jun 5, 2026 5:21am

Request Review

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 4, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6eaed1d708

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/libs/oidc-provider/http-adapter.ts
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.62%. Comparing base (537c39f) to head (b983310).
⚠️ Report is 7 commits behind head on canary.

Additional details and impacted files
@@             Coverage Diff             @@
##           canary   #15478       +/-   ##
===========================================
+ Coverage   70.84%   88.62%   +17.78%     
===========================================
  Files        3255      819     -2436     
  Lines      321112    91889   -229223     
  Branches    29340     7680    -21660     
===========================================
- Hits       227496    81439   -146057     
+ Misses      93434    10268    -83166     
  Partials      182      182               
Flag Coverage Δ
app ?
database ?
packages/agent-manager-runtime 49.69% <ø> (ø)
packages/agent-runtime 80.48% <ø> (ø)
packages/builtin-tool-lobe-agent 18.52% <ø> (ø)
packages/context-engine 84.19% <ø> (ø)
packages/conversation-flow 91.29% <ø> (ø)
packages/device-gateway-client 90.51% <ø> (ø)
packages/eval-dataset-parser 95.15% <ø> (ø)
packages/eval-rubric 76.11% <ø> (ø)
packages/fetch-sse 85.57% <ø> (ø)
packages/file-loaders 87.89% <ø> (ø)
packages/memory-user-memory 74.99% <ø> (ø)
packages/model-bank 99.99% <ø> (ø)
packages/model-runtime 84.51% <ø> (ø)
packages/prompts 72.51% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/types 35.34% <ø> (ø)
packages/utils 84.98% <ø> (ø)
packages/web-crawler 88.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store ∅ <ø> (∅)
Services ∅ <ø> (∅)
Server ∅ <ø> (∅)
Libs ∅ <ø> (∅)
Utils 100.00% <ø> (+18.51%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tjx666

tjx666 commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

@codex review latest code

@tjx666 tjx666 merged commit 95a0cf1 into canary Jun 5, 2026
33 of 36 checks passed
@tjx666 tjx666 deleted the fix/output-json-runtime-errors branch June 5, 2026 05:13
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant