Skip to content

feat: finer grained error codes#745

Merged
gilescope merged 8 commits into
mainfrom
giles-error-fidelity
Feb 23, 2026
Merged

feat: finer grained error codes#745
gilescope merged 8 commits into
mainfrom
giles-error-fidelity

Conversation

@gilescope

@gilescope gilescope commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Overview

To aid debugging / developer experience.
Also corrects rust-toolkit.toml

Breaking changes:

🗹 TODO before merging

  • Ready

📌 Submission Checklist

  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason:
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • Updated AGENTS.md if build commands, architecture, or workflows changed
  • No new todos introduced

🧪 Testing Evidence

Please describe any additional testing aside from CI:

  • Additional tests are provided (if possible): Ensure we can't use the same error code twice.

🔱 Fork Strategy

  • Node Runtime Update
  • Node Client Update
  • Other:
  • N/A

Links

Signed-off-by: Giles Cope <gilescope@gmail.com>
@github-actions

github-actions Bot commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

kics-logo

KICS version: v2.1.16

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 96
LOW LOW 12
INFO INFO 83
TRACE TRACE 0
TOTAL TOTAL 191
Metric Values
Files scanned placeholder 31
Files parsed placeholder 31
Files failed to scan placeholder 0
Total executed queries placeholder 73
Queries failed to execute placeholder 0
Execution time placeholder 9

…retty quickly.

Signed-off-by: Giles Cope <gilescope@gmail.com>
Signed-off-by: Giles Cope <gilescope@gmail.com>
Signed-off-by: Giles Cope <gilescope@gmail.com>
@gilescope gilescope marked this pull request as ready for review February 23, 2026 07:34
@gilescope gilescope requested a review from a team as a code owner February 23, 2026 07:34
Signed-off-by: Giles Cope <gilescope@gmail.com>
Signed-off-by: Giles Cope <gilescope@gmail.com>
Signed-off-by: Giles Cope <gilescope@gmail.com>
Signed-off-by: Giles Cope <gilescope@gmail.com>
@gilescope gilescope enabled auto-merge February 23, 2026 09:56
@gilescope gilescope added this pull request to the merge queue Feb 23, 2026
Merged via the queue into main with commit 2e5a5b1 Feb 23, 2026
40 checks passed
@gilescope gilescope deleted the giles-error-fidelity branch February 23, 2026 12:26

@m2ux m2ux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary

PR: #745 — feat: finer grained error codes
Issue: PM-21798
Reviewer: Workflow-based review (retrospective)
Date: 2026-02-23

Executive Summary

Solid implementation that correctly resolves the u8 error code collision between MalformedError::UnknownError and SystemTransactionError::IllegalPayout (both formerly mapped to 139). The enum expansion, code reassignment, and brute-force regression test are well-designed. Two documentation gaps and a scope concern are noted below.

Overall Rating: Approve (with comments)


Code Review Findings

Severity Category Finding Location
Medium Documentation Range reservation comment // Reserved from [150-255) is now inaccurate — codes 166–210 are actively used types.rs:406
Medium Documentation Range reservation comment // Reserved from [100-150) no longer holds — transaction error codes now span [100–139] + [166–210] types.rs:312
Low Documentation Non-contiguous u8 ranges (e.g., InvalidError using 100–109 and 193–200) lack inline rationale explaining the backward-compatibility motivation types.rs, From<LedgerApiError> for u8 impl
Low Documentation Change file doesn't explicitly mention that all SystemTransactionError codes shifted from 139–148 to 201–210 — downstream consumers may miss this changes/added/finer-grained-error-codes.md

Strengths

  • Brute-force regression test (error_codes_are_unique) is self-adapting via SCALE decoding — automatically covers new variants without manual maintenance
  • Defensive fallback with log::warn! for unmapped variants provides forward compatibility
  • Backward compatibility preserved for existing codes 0–138
  • Clean variant naming — intermediate enum variants mirror source enum names exactly

Test Review Findings

Area Assessment Notes
Collision prevention Covered Core requirement validated by error_codes_are_unique
Backward compatibility Gap (medium) No assertion that specific existing codes (e.g., EffectsMismatch => 100) are unchanged
Per-variant correctness Gap (low) Specific code assignments not asserted (uniqueness is, values are not)
Fallback logging Acceptable gap Requires a future unknown variant to test — inherently difficult

Recommendation: Consider adding a few spot-check assertions for sentinel values (e.g., assert_eq!(u8::from(InvalidError::EffectsMismatch.into()), 100)) to catch accidental enum reordering.


Validation Results

Check Result
CI — Build Pass
CI — Tests (unit + E2E) Pass
CI — Formatting & Linting Pass
CI — Metadata Check Pass
CI — Merge Queue Passed and merged

All CI checks passed. The PR was merged via merge queue.


Scope Observation

The Rust toolchain bump (1.90 → 1.93) and cargo-nextest pin (0.9.128) are bundled with this PR but are not required by any feature used in the error code changes. For future PRs, consider separating infrastructure changes (toolchain, CI config) into dedicated PRs to simplify bisection and review.


Action Items

Should Address (follow-up):

  1. Update the two range reservation comments in types.rs to reflect actual code allocation
  2. Add a note to the change file about SystemTransactionError code reassignment (139–148 → 201–210)

Nice to Have:
3. Add inline comment explaining why new InvalidError codes start at 193 instead of 110
4. Add backward-compatibility spot-check assertions to the test

gilescope pushed a commit that referenced this pull request Apr 8, 2026
m2ux added a commit that referenced this pull request Apr 23, 2026
Signed-off-by: Mike Clay <mike.clay@shielded.io>
m2ux added a commit that referenced this pull request Apr 23, 2026
Signed-off-by: Mike Clay <mike.clay@shielded.io>
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.

3 participants