Skip to content

refactor(jwtinfo): add sentinel and typed errors for Is/As - #48

Merged
xenOs76 merged 2 commits into
mainfrom
refactor/errors_jwtinfo
Sep 11, 2026
Merged

xenOs76 merged 2 commits into
mainfrom
refactor/errors_jwtinfo

Conversation

@xenOs76

@xenOs76 xenOs76 commented Sep 11, 2026 •

Copy link
Copy Markdown
Owner

Expose stable jwtinfo failure conditions via sentinels and typed errors, and route CLI/MCP display through errdisp domain leaves.

Co-authored-by: Cursor cursoragent@cursor.com

Summary by CodeRabbit

  • New Features

    • Added clearer, more consistent JWT error messages in the jwtinfo command.
    • Improved identification of issues such as malformed tokens, invalid claims, request failures, and invalid parameters.
  • Bug Fixes

    • Standardized error formatting across token reading, parsing, decoding, and refresh operations.
  • Tests

    • Expanded coverage for JWT validation, error categorization, and wrapped error handling.
  • Documentation

    • Added an unreleased changelog entry describing the updated JWT error handling.

Expose stable jwtinfo failure conditions via sentinels and typed errors,
and route CLI/MCP display through errdisp domain leaves.

  Co-authored-by: Cursor <cursoragent@cursor.com>
@xenOs76 xenOs76 self-assigned this Sep 11, 2026
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 9c140e05-b827-48c7-9be2-fd84974822a1

📥 Commits

Reviewing files that changed from the base of the PR and between 31b5b8d and ddde668.

📒 Files selected for processing (4)
  • internal/errdisp/errdisp_test.go
  • internal/jwtinfo/errors_test.go
  • internal/jwtinfo/jwtinfo_refresh_test.go
  • internal/jwtinfo/jwtinfo_test.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • internal/jwtinfo/errors_test.go
  • internal/jwtinfo/jwtinfo_refresh_test.go
  • internal/errdisp/errdisp_test.go
  • internal/jwtinfo/jwtinfo_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

jwtinfo now returns sentinel and typed errors across token workflows. errdisp formats JWT errors by domain. The jwtinfo command uses this formatter for operational and refresh-loop errors. Tests validate errors.Is, errors.AsType, and formatted output.

Changes

JWT error classification

Layer / File(s) Summary
JWT error contracts and producers
internal/jwtinfo/errors.go, internal/jwtinfo/jwtinfo.go
jwtinfo adds sentinel and typed errors. Request validation, JWT parsing, claim handling, timing, and key-value parsing now return structured errors.
JWT error matching tests
internal/jwtinfo/*_test.go
Tests validate sentinel matching, typed error extraction, preserved fields, and structured assertions across JWT workflows.

Domain error display

Layer / File(s) Summary
Domain error formatting
internal/errdisp/errdisp.go, internal/errdisp/errdisp_test.go
errdisp recognizes jwtinfo typed errors and sentinels and returns their domain messages.
CLI error output
internal/cmd/jwtinfo.go, CHANGELOG.md
The jwtinfo command formats operational and refresh-loop errors with errdisp.FormatCause. The changelog records the error model and display integration.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant jwtinfo
  participant jwtinfoCommand
  participant errdisp
  jwtinfo-->>jwtinfoCommand: return typed or sentinel error
  jwtinfoCommand->>errdisp: FormatCause(error)
  errdisp->>errdisp: resolve jwtinfo domain leaf
  errdisp-->>jwtinfoCommand: formatted error message
  jwtinfoCommand-->>jwtinfoCommand: display formatted message
Loading

Merge Risk: ⚪ Minimal · up to ddde6

No current merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: adding sentinel and typed errors to support errors.Is and errors.As in jwtinfo.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/errors_jwtinfo

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@xenOs76
xenOs76 merged commit 57139d1 into main Sep 11, 2026
5 checks passed
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.

1 participant