Skip to content

Feat/jwtinfo request flags#32

Merged
xenOs76 merged 3 commits into
mainfrom
feat/jwtinfo_request_flags
May 4, 2026
Merged

Feat/jwtinfo request flags#32
xenOs76 merged 3 commits into
mainfrom
feat/jwtinfo_request_flags

Conversation

@xenOs76
Copy link
Copy Markdown
Owner

@xenOs76 xenOs76 commented May 4, 2026

Summary by CodeRabbit

  • Documentation

    • Reformatted example commands in README with clearer multi-line invocations for better readability.
    • Expanded jwtinfo examples to demonstrate combined flag usage.
  • New Features

    • Enhanced jwtinfo command to support combined request-value flags for greater flexibility.
  • Bug Fixes

    • Added validation requiring --request-url when using --refresh flag.
  • Tests

    • Expanded test coverage with additional scenarios and improved test structure.

@xenOs76 xenOs76 self-assigned this May 4, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@xenOs76 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 55 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e1d578b1-6960-4529-b124-56d947ae291e

📥 Commits

Reviewing files that changed from the base of the PR and between d429101 and e8c66a8.

📒 Files selected for processing (2)
  • internal/jwtinfo/jwtinfo.go
  • internal/jwtinfo/jwtinfo_test.go
📝 Walkthrough

Walkthrough

The PR refactors the jwtinfo command to support ordered, mixed request-value flags (--request-values, --request-values-file, --request-values-json) collected in a slice, adds a ParseKVValue helper for key-value parsing, enforces that --refresh requires --request-url, and updates tests to use direct command execution with HTTP mocking.

Changes

Request-Value Flag Handling Refactor

Layer / File(s) Summary
Data Shape & Interfaces
internal/cmd/jwtinfo.go
New requestSteps slice of requestValueStep structs; stepFlag type implements pflag.Value to track flag occurrences with kind and value.
Core Parsing Helper
internal/jwtinfo/jwtinfo.go
New ParseKVValue(kv, reqValuesMap) helper validates and parses "key=value" strings, updates the map, and returns the result or error.
Command Implementation
internal/cmd/jwtinfo.go
Refactored jwtinfoCmd.Run to iterate over requestSteps and build requestValuesMap by calling JSON/file/kv parsing per step. Added early validation: if --refresh is set, --request-url must be provided (error printed and command returns early).
Flag Wiring & Validation
internal/cmd/jwtinfo.go
Registered stepFlag as pflag.Value for --request-values-json, --request-values-file, and --request-values (new). Removed old StringVar registrations for single-value request inputs.
Tests
internal/cmd/jwtinfo_test.go, internal/jwtinfo/jwtinfo_test.go
Refactored CLI test from root command execution to two focused tests: TestJwtinfoCmd_Errors (error scenarios with flag reset) and TestJwtinfoCmd_Success (with mocked HTTP token server). Added resetFlags() helper. New TestParseKVValue covers success, overwrite, and error cases.
Documentation & Examples
README.md, devenv.nix
Reformatted certinfo and jwtinfo examples as multi-line shell commands with continuations. Added new devenv.nix script testing jwtinfo with mixed --request-values and --request-values-file flags against Keycloak.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Step by step, the flags align,
Mixing values, fine design!
Key and value, parsed with care,
Ordered tokens float through air.
Tests now mock what once was real,
Magic in each swift reveal!

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feat/jwtinfo request flags' directly relates to the main changeset, which adds new request-value flag handling (--request-values, --request-values-file, --request-values-json) to the jwtinfo command with supporting infrastructure.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/jwtinfo_request_flags

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
Review rate limit: 0/1 reviews remaining, refill in 24 minutes and 55 seconds.

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/jwtinfo/jwtinfo.go`:
- Around line 725-735: The current parsing of kv using parts :=
strings.SplitN(kv, "=", 2) allows inputs like "=value" and creates an empty key;
update the validation to reject empty parameter names: after splitting, check
that parts[0] is not an empty string and return an error (e.g.,
fmt.Errorf("empty request parameter name in: %s", kv)) if it is; keep the rest
of the logic that clones reqValuesMap into newMap and sets newMap[parts[0]] =
parts[1] unchanged so only invalid empty keys are blocked.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e4df4153-2e86-476c-8b24-b342ad60d55f

📥 Commits

Reviewing files that changed from the base of the PR and between 6275eda and d429101.

⛔ Files ignored due to path filters (1)
  • devenv.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • README.md
  • devenv.nix
  • internal/cmd/jwtinfo.go
  • internal/cmd/jwtinfo_test.go
  • internal/jwtinfo/jwtinfo.go
  • internal/jwtinfo/jwtinfo_test.go

Comment thread internal/jwtinfo/jwtinfo.go Outdated
@xenOs76 xenOs76 merged commit 0d561e3 into main May 4, 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