fix(core)(#191): promote errMessage helper; fix lossy NametagMinter stringification#192
Merged
Merged
Conversation
5 tasks
…er stringification
Operators saw `Submit failed: [object Object]` from `Sphere.init({ nametag })`
against the testnet aggregator because `NametagMinter` used the inline
`err instanceof Error ? err.message : String(err)` pattern, which collapses
non-Error throws (structured RPC payloads) to the default Object#toString
output. Issue #191 reports 35/35 e2e tests failing this way.
Promote the existing `errMessage` helper (previously local to
`modules/payments/transfer/nostr-persistence-verifier.ts`) to `core/errors.ts`
so it lives next to `redactCause` and is importable from any module.
`errMessage` routes unknown-shape errors through `redactCause` +
`JSON.stringify`, so the surfaced string carries field-level forensics
without leaking W40-redacted secret bytes.
Replace the two highest-visibility callsites in NametagMinter (the
submit-retry catch at :182 and the outer mintNametag catch at :256) with
`errMessage(error)`. The output for a rejected aggregator response now
reads e.g. `Submit failed: {"status":"BAD_REQUEST","reason":"..."}` —
immediately actionable.
The remaining ~89 occurrences of the lossy pattern in core/ and modules/
are intentionally left alone per the issue's "Optional follow-up" note —
they surface in warn-logs / internal worker paths rather than user-facing
errors and a bulk replacement would inflate this PR's scope.
a570d94 to
a2ac81d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #191 —
Sphere.init({ nametag })failures surfacing asSubmit failed: [object Object]instead of the aggregator's structured rejection.errMessagehelper frommodules/payments/transfer/nostr-persistence-verifier.tstocore/errors.ts, next toredactCause/SphereError. The helper routes unknown-shape errors throughredactCause+JSON.stringify, preserving field-level forensics while keeping W40 secret-byte redaction intact.modules/payments/NametagMinter.ts(submit-retry catch at :182 and the outermintNametagcatch at :256) witherrMessage(error).nostr-persistence-verifier.tsto import the promoted helper instead of defining its own copy.tests/unit/core/errors.errMessage.test.tscovering: Error instances, custom Error subclasses, string throws, structured-object throws (the issue Lossy error stringification in NametagMinter —[object Object]masks aggregator failure reason #191 reproducer), aggregator-shaped payloads, W40 redaction integration, arrays, null/undefined, BigInt unstringifiables, and cycle-safety.Out of scope
The remaining ~89 occurrences of
err instanceof Error ? err.message : String(err)incore/andmodules/are deferred per the issue's "Optional follow-up" note — they surface in warn-logs / internal worker paths rather than user-facing errors. A bulk replacement would inflate this PR's scope.Test plan
npx vitest run tests/unit/core/errors.errMessage.test.ts— 10/10 passnpx vitest run tests/unit/payments/transfer/sphere-error-redaction.test.ts— 44/44 pass (no W40 regression)npx vitest run tests/unit/modules/NametagMinter.test.ts tests/unit/payments/transfer/nostr-persistence-verifier.test.ts— 46/46 passnpx vitest run tests/unit/core/— 451/451 passnpx vitest run tests/unit/payments/ tests/unit/modules/— 3181/3181 passnpm run typecheck— cleannpx eslinton the four changed files — clean[object Object]) — requires testnet accessBefore / after
Before:
After (when aggregator returns a structured error):