Skip to content

fix: DSN token precedence — prefer Bearer, parse URL-shaped dsn (fixes #1) - #4

Merged
yzzztech merged 2 commits into
mainfrom
fix/dsn-precedence-v2
May 24, 2026
Merged

fix: DSN token precedence — prefer Bearer, parse URL-shaped dsn (fixes #1)#4
yzzztech merged 2 commits into
mainfrom
fix/dsn-precedence-v2

Conversation

@yzzztech

Copy link
Copy Markdown
Owner

Fix: DSN token precedence — prefer Bearer, parse URL-shaped dsn

Fixes #1

Problem

When a client sends the full DSN URL (http://TOKEN@host:3456/api/ingest/PROJECT_ID) in the JSON body's dsn field — which the official Claude Code hook does — the full URL shadowed the Bearer token. Prisma lookup fails searching for the full URL as a token.

Result: all Claude Code events silently dropped with 401 Invalid DSN token.

Fix (minimal — 6 lines added)

// Before:  const dsnToken = dsn || bearerToken;
// After:   Bearer > token from URL > plain dsn

let dsnFromUrl: string | undefined;
if (typeof dsn === "string" && dsn.includes("@")) {
  const match = dsn.match(/:\\/\\/([^@]+)@/);
  dsnFromUrl = match?.[1];
}
const dsnToken = bearerToken || dsnFromUrl || (typeof dsn === "string" ? dsn : undefined);

Files changed

  • apps/web/app/api/ingest/route.ts — DSN precedence fix
  • CHANGELOG.md — v0.2.1 entry

@yzzztech
yzzztech merged commit f9b692b into main May 24, 2026
3 of 4 checks passed
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.

Ingest endpoint silently rejects valid DSN tokens when full DSN URL is in body

1 participant