8000 fix(minimald::rpc::CreateSession): communicate an error if the session name is not unique by twitchyliquid64 · Pull Request #381 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(minimald::rpc::CreateSession): communicate an error if the session name is not unique - #381

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/session-inner
Jun 12, 2026
Merged

twitchyliquid64 merged 1 commit into
mainfrom
tom/session-inner

Conversation

@twitchyliquid64
@twitchyliquid64 twitchyliquid64 commented Jun 11, 2026 •
Copy link
Copy Markdown
Contributor

Fixes that cheeky no-error-but-didnt-create-a-session we saw during the demo.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Remote procedure call failures now return detailed error messages to clients instead of causing silent failures.
    • Session creation operations now properly validate and fail gracefully with error reporting.
  • New Features

    • Attempting to create a session with a duplicate name now returns a specific error message, providing clear feedback to users.

@coderabbitai
coderabbitai Bot commented Jun 11, 2026 •
Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces an Errorable wrapper enum for RPC responses to represent application-level errors, updates CreateSession to return Errorable<CreateSessionResponse> with proper handling of duplicate-session errors, refactors the sessions actor to use an internal error type, and updates test helpers across multiple subsystems to handle the new response shape.

Changes

RPC Error Response Wrapper

Layer / File(s) Summary
Errorable wrapper type and contract
crates/minimald/src/rpc.rs
Introduces generic Errorable<S> enum with Ok/Err variants, helper methods (unwrap, ok, err), and From<Result<_, _>> conversion for mapping Rust results into RPC payloads.
CreateSession RPC handler with Errorable response
crates/minimald/src/rpc.rs
Updates CreateSession RPC to return Errorable<CreateSessionResponse> and handler logic to map IO AlreadyExists errors into Errorable::Err payloads. Adds PartialEq and Eq derives to CreateSessionResponse.
CreateSession test suite and test helpers
crates/minimald/src/rpc.rs, crates/minimald/src/exec.rs, crates/minimald/src/session.rs, crates/minimald/src/sftp.rs
Updates existing test to unwrap Errorable, adds new test create_session_errors_if_name_not_unique validating duplicate-session errors, and aligns test helpers across subsystems to unwrap the new response wrapper.

Sessions Actor Error Type Refactoring

Layer / File(s) Summary
Sessions error type and responder communication
crates/minimald/src/sessions.rs
Replaces exported ResponseError with internal SessionsError type alias. Updates Responder wrapper and actor message response paths for List and GetRecord to use the new error type.
ManagerHandle method signatures
crates/minimald/src/sessions.rs
Updates all four public async methods (list, get_record, create_session, get_session) to return Result<_, SessionsError> instead of Result<_, ResponseError>.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • gominimal/minimal#374: This PR previously deserialized the CreateSession RPC response; these changes wrap that response in the new Errorable type to carry error payloads.

Suggested reviewers

  • evanspearman
  • 0chroma
  • norrietaylor

Poem

🐰 A wrapper soft called Errorable,
Lets responses tell what's deplorable,
No sessions alike shall dwe 8000 ll,
Each error now has tales to tell,
Code flows clear and more adorable! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding error communication to CreateSession when session names are not unique, which is the primary objective of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 docstrings
  • Create stacked PR
  • Commit on current branch

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

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
crates/minimald/src/rpc.rs (1)

67-103: Drop the redundant Debug + PartialEq bounds from Errorable<S>

Errorable is declared as pub enum Errorable<S: std::fmt::Debug + PartialEq>, but its methods (unwrap/ok/err) and its From<Result<T, E>> impl don’t rely on Debug/PartialEq. Since Errorable already derives Debug, PartialEq, and Eq, the required trait bounds are naturally enforced only when those trait impls are used—so the declaration-level bounds unnecessarily restrict every Errorable<T>.

♻️ Proposed fix
-pub enum Errorable<S: std::fmt::Debug + PartialEq> {
+pub enum Errorable<S> {
     Ok(S),
     Err { error: String },
 }

-impl<S: std::fmt::Debug + PartialEq> Errorable<S> {
+impl<S> Errorable<S> {
     pub fn unwrap(self) -> S {
         match self {
             Self::Ok(s) => s,
             Errorable::Err { error } => panic!("unwrap of error value: {error}"),
         }
     }
@@
-impl<T: std::fmt::Debug + PartialEq, E: ToString> From<Result<T, E>> for Errorable<T> {
+impl<T, E: ToString> From<Result<T, E>> for Errorable<T> {
     fn from(value: Result<T, E>) -> Self {
         match value {
             Err(e) => Self::Err {
                 error: e.to_string(),
             },
             Ok(t) => Self::Ok(t),
         }
     }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/minimald/src/rpc.rs` around lines 67 - 103, The enum declaration
imposes unnecessary type bounds: remove "S: std::fmt::Debug + PartialEq" from
"pub enum Errorable<S>" so the enum itself is generic over S without those
constraints, and adjust the impl blocks accordingly (the inherent impl impl<S>
Errorable<S> and the From<Result<T, E>> impl should not require Debug+PartialEq
on S; keep the From impl generic as "impl<T, E: ToString> From<Result<T, E>> for
Errorable<T>"). Ensure references to Errorable::Ok/Err, unwrap, ok, err, and the
From<Result<T, E>> remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/minimald/src/rpc.rs`:
- Around line 67-103: The enum declaration imposes unnecessary type bounds:
remove "S: std::fmt::Debug + PartialEq" from "pub enum Errorable<S>" so the enum
itself is generic over S without those constraints, and adjust the impl blocks
accordingly (the inherent impl impl<S> Errorable<S> and the From<Result<T, E>>
impl should not require Debug+PartialEq on S; keep the From impl generic as
"impl<T, E: ToString> From<Result<T, E>> for Errorable<T>"). Ensure references
to Errorable::Ok/Err, unwrap, ok, err, and the From<Result<T, E>> remain
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e3723a4d-661b-4627-a1c3-e960dba7045b

📥 Commits

Reviewing files that changed from the base of the PR and between 56f9449 and 2544f48.

📒 Files selected for processing (5)
  • crates/minimald/src/exec.rs
  • crates/minimald/src/rpc.rs
  • crates/minimald/src/session.rs
  • crates/minimald/src/sessions.rs
  • crates/minimald/src/sftp.rs

@twitchyliquid64
twitchyliquid64 enabled auto-merge (rebase) June 11, 2026 19:25
@twitchyliquid64
twitchyliquid64 merged commit d13012f into main Jun 12, 2026
29 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/session-inner branch June 12, 2026 01:05
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.

2 participants

0