chore: ban nested ternaries via biome#544
Merged
Merged
Conversation
SgtPooki
commented
May 18, 2026
Collaborator
Author
SgtPooki
left a comment
There was a problem hiding this comment.
self review.. lgtm
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enforces a consistent code style across the repo by enabling Biome’s style/noNestedTernary rule as an error (CI-failing), and updates the two existing nested-ternary violations to compliant, clearer implementations. It also centralizes “flat” error-message extraction logic to preserve low-cardinality failureReason fields for logging/observability use cases.
Changes:
- Enable Biome
style/noNestedTernary: "error"repo-wide. - Refactor the web Landing page’s approved-SP dashboard URL selection to a
Record<Network, ...>lookup. - Add
getErrorMessage(error: unknown)in backend logging utilities and use it foripni_tracking_failed.failureReason.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
biome.json |
Enforces noNestedTernary as an error to prevent nested ternaries repo-wide. |
apps/web/src/pages/Landing.tsx |
Replaces nested ternary network URL selection with a typed lookup map. |
apps/backend/src/deal-addons/strategies/ipni.strategy.ts |
Uses getErrorMessage for failureReason to avoid nested ternary and keep logs aggregable. |
apps/backend/src/common/logging.ts |
Introduces getErrorMessage built on toStructuredError redaction semantics. |
silent-cipher
approved these changes
May 18, 2026
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
style/noNestedTernary: errorrepo-wide so nested ternaries fail CI.apps/web/src/pages/Landing.tsx: replace nested ternary pickingapprovedSpDashboardUrlby network with aRecord<Network, ...>lookup (gains compile-time exhaustiveness ifNetworkgrows).apps/backend/src/deal-addons/strategies/ipni.strategy.ts: replace inline nested ternary onfailureReasonwith a newgetErrorMessagehelper.getErrorMessage(error: unknown): stringinapps/backend/src/common/logging.ts. Derives fromtoStructuredError(so redaction is inherited) and preferscause.messageover outermessagewhen the cause is a realError— preserves PR feat(ipni): expose failureReason as top-level field on ipni_tracking_failed #491 / issue IPNI xxx root CID not verified #473 intent of keepingfailureReasonaggregable in BetterStack/Grafana (no high-cardinality deal IDs in the flat field). Guards against non-Error causes leaking"Non-Error thrown".Peer-reviewed in three rounds via Claude, Cursor, and Gemini agents; consensus approved after the cause-preferred semantics were restored and the
cause.type === "error"guard added.Test plan
pnpm lint:check— passes (the only remaining warning is in an untracked scratch file).pnpm build(apps/backend) — passes.pnpm typecheck(apps/web) — passes.pnpm vitest run src/common/logging.spec.ts src/deal-addons/strategies/ipni.strategy.spec.ts— 23/23 pass.WHERE event = 'ipni_tracking_failed' GROUP BY failureReasonstill buckets cleanly (no deal-ID prefix regression).