Skip to content

feat: implement delete client#15

Merged
NathaelB merged 2 commits intomainfrom
feat/delete-client
May 4, 2026
Merged

feat: implement delete client#15
NathaelB merged 2 commits intomainfrom
feat/delete-client

Conversation

@NathaelB
Copy link
Copy Markdown
Member

@NathaelB NathaelB commented May 4, 2026

Summary by CodeRabbit

  • New Features
    • Implemented client deletion functionality with support for multiple output formats including table, JSON, and YAML.
    • Added standardized output formatting for consistent command messaging.

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

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@NathaelB has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 15 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: beb5be80-c401-445a-a5ea-25002b8c79e7

📥 Commits

Reviewing files that changed from the base of the PR and between f51dda6 and 22907d2.

📒 Files selected for processing (1)
  • libs/ferriskey-cli-core/src/client.rs
📝 Walkthrough

Walkthrough

The PR implements client deletion functionality in the CLI. Previously unimplemented, the delete_client handler now resolves context and realm, obtains an admin token via client-credentials exchange, retrieves the target client, deletes it via API, and outputs a formatted success message. A render_message helper standardizes output across table, JSON, and YAML formats.

Changes

Client Deletion Feature

Layer / File(s) Summary
Command Dispatch
libs/ferriskey-cli-core/src/client.rs
run now routes ClientSubcommand::Delete to the new delete_client handler instead of returning unimplemented error.
Core Implementation
libs/ferriskey-cli-core/src/client.rs
delete_client function resolves context and realm, exchanges client-credentials for an access token, looks up the client by ID, deletes it via API, and handles errors if client is not found.
Output Formatting
libs/ferriskey-cli-core/src/client.rs
render_message helper prints plain output for table format or structured JSON/YAML containing the message, with error handling for unsupported formats.
Module Exports
libs/ferriskey-commands/src/lib.rs
ClientDeleteArgs is added to the public re-exports from the client module.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A delete command blooms, where silence once dwelt,
Client records vanish with an admin-credential belt,
In table, JSON, or YAML's embrace,
Success messages render with output-formatting grace!

🚥 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: implement delete client' accurately and concisely describes the main change—implementing the delete client functionality across the codebase.
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/delete-client

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 49 minutes and 15 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: 2

🧹 Nitpick comments (2)
libs/ferriskey-cli-core/src/client.rs (2)

111-111: 💤 Low value

Unnecessary .clone() on args.realm.

args.realm is not read after line 111, so it can be moved directly into resolve_realm instead of cloned.

♻️ Proposed fix
-    let realm = resolve_realm(&context, args.realm.clone())?;
+    let realm = resolve_realm(&context, args.realm)?;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/ferriskey-cli-core/src/client.rs` at line 111, The call to resolve_realm
is cloning args.realm unnecessarily; change the call to move the value instead
by passing args.realm (by value) rather than args.realm.clone() so ownership of
the realm is transferred into resolve_realm; ensure any later uses of args.realm
are removed or adjusted (e.g., update references in the surrounding function)
and keep the function signature of resolve_realm as resolve_realm(&context,
realm) to accept the moved String/value.

459-601: 🏗️ Heavy lift

No tests for delete_client or render_message.

The existing test suite covers select_context, resolve_realm, and build_create_client_request, but has no coverage for the newly introduced delete_client and render_message. At minimum, render_message is straightforward to unit-test with the three output formats, and the uuid-missing error path in delete_client should be exercised.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/ferriskey-cli-core/src/client.rs` around lines 459 - 601, Add unit tests
under the existing #[cfg(test)] mod to cover render_message and the error path
in delete_client: write three tests that call render_message with
MessageFormat::Json, MessageFormat::Yaml, and MessageFormat::Text and assert the
output format/content matches expectations; and add a test that constructs a
ClientDeleteArgs (or calls delete_client helper) with a missing/None uuid to
assert it returns the expected error (ClientCommandError::MissingUuid or
whichever variant delete_client uses). Reference the render_message function and
delete_client (or the ClientDeleteArgs type) when adding these tests so they
live alongside the other tests in the same file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@libs/ferriskey-cli-core/src/client.rs`:
- Around line 119-123: The code currently uses found.id.unwrap_or_default()
which silently yields an empty string and then calls client.delete_client with
that empty UUID; change this to explicitly handle the Option returned by
found.id and return a clear error instead of an empty string. For example, after
obtaining found from client.get_client, check found.id (or use
found.id.ok_or_else(...)) and return a ClientCommandError variant (e.g.
ClientCommandError::MissingClientId or ClientCommandError::ClientHasNoId with
args.client_id.clone()) when id is None, only calling
client.delete_client(&realm, &uuid)? when a non-empty UUID is present; update
the call sites around get_client, found.id, and delete_client accordingly.
- Around line 411-413: The JSON branch currently prints compact JSON with
println!("{}", serde_json::json!({ "message": message })), causing inconsistent
formatting versus other renderers (render_client_detail, render_client_list,
render_created_client); change this match arm to produce pretty-printed JSON
using serde_json::to_string_pretty(&serde_json::json!({ "message": message }))
and then println! the resulting String (or propagate/unwrap the Result in the
same style used by the other render functions) so the delete output matches the
pretty formatting used elsewhere.

---

Nitpick comments:
In `@libs/ferriskey-cli-core/src/client.rs`:
- Line 111: The call to resolve_realm is cloning args.realm unnecessarily;
change the call to move the value instead by passing args.realm (by value)
rather than args.realm.clone() so ownership of the realm is transferred into
resolve_realm; ensure any later uses of args.realm are removed or adjusted
(e.g., update references in the surrounding function) and keep the function
signature of resolve_realm as resolve_realm(&context, realm) to accept the moved
String/value.
- Around line 459-601: Add unit tests under the existing #[cfg(test)] mod to
cover render_message and the error path in delete_client: write three tests that
call render_message with MessageFormat::Json, MessageFormat::Yaml, and
MessageFormat::Text and assert the output format/content matches expectations;
and add a test that constructs a ClientDeleteArgs (or calls delete_client
helper) with a missing/None uuid to assert it returns the expected error
(ClientCommandError::MissingUuid or whichever variant delete_client uses).
Reference the render_message function and delete_client (or the ClientDeleteArgs
type) when adding these tests so they live alongside the other tests in the same
file.
🪄 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: 7c5f0264-8f0d-4ff8-97e9-ee1763aca09b

📥 Commits

Reviewing files that changed from the base of the PR and between 79b94ee and f51dda6.

📒 Files selected for processing (2)
  • libs/ferriskey-cli-core/src/client.rs
  • libs/ferriskey-commands/src/lib.rs

Comment thread libs/ferriskey-cli-core/src/client.rs
Comment thread libs/ferriskey-cli-core/src/client.rs
@NathaelB NathaelB merged commit 8d7ae6f into main May 4, 2026
1 check was pending
@NathaelB NathaelB deleted the feat/delete-client branch May 4, 2026 08:04
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