Skip to content

refactor(jwtinfo): ParseTokenData function to Parse methods#22

Merged
xenOs76 merged 1 commit intomainfrom
refactor/parse_function_to_method
Mar 25, 2026
Merged

refactor(jwtinfo): ParseTokenData function to Parse methods#22
xenOs76 merged 1 commit intomainfrom
refactor/parse_function_to_method

Conversation

@xenOs76
Copy link
Copy Markdown
Owner

@xenOs76 xenOs76 commented Mar 25, 2026

Summary by CodeRabbit

  • Improvements
    • JWT validation now conditionally applies JWKS endpoint verification when available.
    • Refined token validity display in command output.
    • Enhanced styling for token information presentation.

@xenOs76 xenOs76 self-assigned this Mar 25, 2026
@xenOs76
Copy link
Copy Markdown
Owner Author

xenOs76 commented Mar 25, 2026

@coderabbitai help

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

1 similar comment
@coderabbitai

This comment was marked as duplicate.

@xenOs76
Copy link
Copy Markdown
Owner Author

xenOs76 commented Mar 25, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The pull request refactors JWT token parsing from a function-based to a method-based approach on the JwtTokenData type. Token fields are renamed to separate raw strings from parsed JWT objects. Conditional JWKS-based parsing replaces unconditional parsing. A new style constant is added for UI consistency.

Changes

Cohort / File(s) Summary
JWT Parsing Refactoring
internal/jwtinfo/jwtinfo.go
Removed ParseTokenData function and added two pointer-receiver methods: ParseUnverified() and ParseWithJWKS(). Renamed token fields to AccessTokenRaw/RefreshTokenRaw with new AccessTokenJwt/RefreshTokenJwt fields storing parsed tokens. Updated PrintTokenInfo to display validity indicator from parsed token state.
Command Integration
cmd/jwtinfo.go
Updated command execution to conditionally call tokenData.ParseWithJWKS() when jwksURL is provided, removing unconditional parsing and token validity printing.
Test Suite Updates
internal/jwtinfo/jwtinfo_test.go
Renamed and restructured tests to match new API: TestParseTokenDataTestParseWithJWKS, added TestParseUnverified, and new TestParseWithJWKS_Errors. Updated all test setup to use AccessTokenRaw/RefreshTokenRaw fields and validate token state via AccessTokenJwt.Valid.
Styling
internal/style/style.go
Added new exported Title2 style variable with catBase foreground, catPeach background, bold text, and horizontal padding.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 From functions to methods, we hop and we skip,
JWT tokens now ride on a method-based trip,
Raw strings and parsed friends, together they stay,
A cleaner abstraction to parse the JWKS way! 🔐

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring: converting the ParseTokenData function into Parse methods (ParseUnverified and ParseWithJWKS).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/parse_function_to_method

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 and usage tips.

@xenOs76 xenOs76 merged commit 6631032 into main Mar 25, 2026
2 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