Skip to content

Commit 7c28f80

Browse files
committed
fix: wrap makeDsn in try/catch in buildEnvelopeUrl + fix generic error message
- makeDsn may throw SentryError internally; wrap in try/catch for safety - requireDsn error message now uses canonical 'sentry send event' instead of hardcoded 'sentry send-event' (wrong for send-envelope callers)
1 parent b6f5bab commit 7c28f80

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/lib/envelope/transport.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ export type DsnFlags = {
2929
* Throws ValidationError on an unparseable DSN.
3030
*/
3131
export function buildEnvelopeUrl(dsn: string): string {
32-
const dsnComponents = makeDsn(dsn);
32+
let dsnComponents;
33+
try {
34+
dsnComponents = makeDsn(dsn);
35+
} catch {
36+
// makeDsn may throw a SentryError on malformed input
37+
dsnComponents = undefined;
38+
}
3339
if (!dsnComponents) {
3440
throw new ValidationError(`Invalid DSN: ${dsn}`, "dsn");
3541
}
@@ -69,7 +75,7 @@ export function requireDsn(flags: DsnFlags, cwd: string): string {
6975
}
7076
throw new ConfigError(
7177
"No DSN found. Provide one via --dsn <dsn> or set the SENTRY_DSN environment variable.",
72-
"sentry send-event --dsn <your-dsn>"
78+
"sentry send event --dsn <your-dsn>"
7379
);
7480
}
7581

0 commit comments

Comments
 (0)