Relationships
#4665 A corrupt extension lockfile prints a stack trace instead of a clean error
Opened by zack · 11/11/2026
Summary
When extensions/models/upstream_extensions.json cannot be read as a lockfile (invalid JSON, a non-object, or a repeated key once swamp-club#4663 lands), every extension command fails with a fatal SyntaxError and a full stack trace. In --json mode the stack trace is part of the error payload.
Reproduction
swamp repo initin a temp dir.- Write a lockfile containing only an opening brace and a newline.
- Run
swamp extension listandswamp extension list --json.
Actual
Log mode prints a warning ("Skipping extension catalog repair: ...") and then a fatal line ending in SyntaxError: Cannot parse lockfile <path>: ... followed by the stack trace. JSON mode returns an object with error and stack.
Expected
A user-facing error that names the lockfile and what is wrong with it, with no stack trace (the way UserError is rendered), in both output modes. The warning and the fatal error should not repeat the same message.
Diagnosis
readUpstreamExtensions in src/infrastructure/persistence/upstream_extensions.ts throws a plain SyntaxError (marked with the lockfile path) on purpose, because callers such as the extension list retry and warnLegacyExtensionLayout catch SyntaxError to treat it as a corrupt lockfile. Nothing turns that error into a clean user error at the CLI boundary.
Open
No activity in this phase yet.
Sign in to post a ripple.