Skip to content

fix(api): mask error.message in proxy, upload, and langsmith routes#73

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-api-error-message-leak
Draft

fix(api): mask error.message in proxy, upload, and langsmith routes#73
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-api-error-message-leak

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 16, 2026

Four API routes return error.message verbatim in 500 responses, leaking internal hostnames, ports, filesystem paths, and API key fragments to clients. Admin routes already mask these — proxy/upload/langsmith routes do not.

Changes

  • New shared helper frontend/src/lib/api/error-response.ts:
export function internalErrorResponse(error: unknown, context: string) {
  console.error(`[api] ${context}`, error);
  return NextResponse.json({ error: "Internal server error" }, { status: 500 });
}
  • Replaced raw error.message exposure in:
    • api/[..._path]/route.ts — proxy catch block
    • api/upload/route.ts — user upload catch block
    • api/admin/upload/route.ts — admin upload catch block
    • api/langsmith/runs/route.ts — LangSmith query catch block

Full stack traces remain in server logs via console.error.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkpoint.prisma.io
    • Triggering command: /opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node /home/REDACTED/work/langgraph-chat-ui/langgraph-chat-ui/frontend/node_modules/.pnpm/prisma@5.22.0/node_modules/prisma/build/child {"product":"prisma","version":"5.22.0","cli_install_type":"local","information":"","local_timestamp":"2026-04-16T06:47:23Z","project_hash":"8b888558","cli_path":"/home/REDACTED/work/langgraph-chat-ui/langgraph-chat-ui/frontend/node_modules/prisma/build/inde (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Extract internalErrorResponse helper that logs full error server-side
but returns a generic "Internal server error" to clients, preventing
leakage of internal hostnames, ports, file-system paths, and API keys.

Agent-Logs-Url: https://github.com/teddynote-lab/langgraph-chat-ui/sessions/1e9c771d-26ba-486d-aab0-155cba18d45f

Co-authored-by: teddylee777 <10074379+teddylee777@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix API proxy and upload routes leak error message verbatim fix(api): mask error.message in proxy, upload, and langsmith routes Apr 16, 2026
Copilot AI requested a review from teddylee777 April 16, 2026 06:49
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.

🟠[P1] fix(api): proxy and upload routes leak error.message verbatim to clients

2 participants