Skip to content

admin_add_solver: invalid payload silently returns Ok(()) instead of a proper error #689

@codaMW

Description

@codaMW

Summary

In src/app/admin_add_solver.rs, when the incoming message has a missing or
wrong-typed payload, the handler logs an error but returns Ok(()):

let payload = if let Some(payload) = &inner_message.payload {
    payload
} else {
    error!("No pubkey found!");
    return Ok(());  // ← silent success on invalid input
};
let npubkey = if let Payload::TextMessage(p) = payload {
    p
} else {
    error!("No pubkey found!");
    return Ok(());  // ← same here
};

Impact

  • The admin who sent the malformed request gets no feedback, no DM, no error
  • The call site sees a successful result, making the failure invisible
  • This is inconsistent with every other handler in src/app/ which returns
    Err(MostroCantDo(...)) or Err(MostroInternalErr(...)) for invalid input

Suggested Fix

Replace the silent Ok(()) returns with appropriate errors, for example:

} else {
    return Err(MostroInternalErr(ServiceError::InvalidPayload));
};

This would allow the caller to send a proper error DM to the admin and surface
the failure in logs with the correct severity level.

Related

  • Consistent with how add_invoice_action and admin_take_dispute_action handle
    invalid input they return Err(...) rather than silently returning Ok(())

I wrote a failing test that reproduces this. Add to src/app/admin_add_solver.rs and run:

cargo test admin_add_solver_missing_payload


Output:

test app::admin_add_solver::tests::admin_add_solver_missing_payload_should_return_err_not_ok ... FAILED

BUG REPRODUCED: admin_add_solver_action returned Ok(()) on missing payload
instead of Err. The admin gets no feedback and the failure is invisible to the caller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions