Skip to content

fix(db): numeric project id in DSNs (#328) - #347

Merged
ajianaz merged 4 commits into
developfrom
fix/328-numeric-project-id
Oct 7, 2026
Merged

ajianaz merged 4 commits into
developfrom
fix/328-numeric-project-id

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

What

  • New per-project numeric seq (SQLite migration 20260701000001_project_seq.sql, Postgres 006_project_seq.sql), backfilled for existing rows (SQLite by rowid, Postgres by created_at).
  • DSNs are generated as {scheme}://{key}@{host}/{seq}. rotate_dsn reuses the project's seq.
  • Ingest route /api/{project_id}/envelope/ resolves the segment as numeric seq first, then falls back to the legacy UUID (Store::resolve_project).
  • extract_dsn_key handles any scheme:// (previously hardcoded https://).

Why

Sentry JS SDKs require a numeric project id in the DSN; UUID project ids make validateDsn fail, or silently truncate digit-leading UUIDs. Fixes #328.

Testing

  • cargo test --workspace: 265 pass, 0 fail.
  • cargo test -p trapfall_db --features postgres --test testcontainers_postgres: 12 pass against a real Postgres container (including the new seq test); migration 006 applied to a Postgres 17 container with two legacy rows (seq 1, 2 by created_at), idempotent on re-run.
  • New tests: DSN generation/parsing, SQLite legacy backfill and second migration run, numeric and UUID resolution, integration (numeric path 200, legacy UUID path 200, unknown numeric id 404).
  • Not run: postgres_backend.rs (needs TEST_POSTGRES_URL); clippy with --features postgres.

Notes

  • Existing projects keep their stored UUID DSN until rotated; old DSNs keep working via the fallback.
  • SQLite assigns MAX(seq)+1, so deleting the newest project can reuse its number; the DSN key check still guards against mismatch.
  • trapfalld/src/migrate.rs (Postgres import path) only applies migrations 001 and 002; left unchanged.

🤖 Generated with Claude Code

ajianaz and others added 4 commits October 7, 2026 15:52
Resolves RUSTSEC-2026-0285 (rustls TLS 1.3 handshake) and the devalue,
source-map-js and undici advisories that fail the Security workflow.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JS SDKs require a numeric project id in the DSN path. Add a per-project
seq (migrations for SQLite and Postgres, backfilled), emit DSNs as
{key}@{host}/{seq}, and resolve the ingest path segment by seq with a
legacy UUID fallback so existing DSNs keep working. extract_dsn_key now
handles any scheme.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ajianaz
ajianaz merged commit 100fe52 into develop Oct 7, 2026
16 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.

Interop: UUID project ids in DSNs break all JS-family SDKs (validateDsn requires numeric; digit-leading UUIDs silently truncate)

1 participant