Skip to content

Replace todo!() panics with structured errors for unsupported ScAddress types in signer #2547

Open
Rachit2323 wants to merge 2 commits intostellar:mainfrom
Rachit2323:fix/replace-todo-panics-with-errors-in-signer
Open

Replace todo!() panics with structured errors for unsupported ScAddress types in signer #2547
Rachit2323 wants to merge 2 commits intostellar:mainfrom
Rachit2323:fix/replace-todo-panics-with-errors-in-signer

Conversation

@Rachit2323
Copy link
Copy Markdown

What:
Three ScAddress variants (MuxedAccount, ClaimableBalance, LiquidityPool) in
signer/mod.rs were hitting todo!() macros instead of returning proper errors.
Replaced them with structured Error variants and added a unit test.

Why:
If a Soroban auth entry contains one of these address types, the CLI crashes
with a panic instead of showing a useful message. This is a bad experience —
users see a raw thread panic with no guidance. Now they get a clear error and
the process exits cleanly.

Known limitations:
MuxedAccount signing is not implemented yet — this just makes the failure
graceful. Full support can be added in a follow-up.

…ss types in signer

Three ScAddress variants (MuxedAccount, ClaimableBalance, LiquidityPool) were
hitting todo!() macros which panic and crash the CLI process when encountered
in Soroban authorization entries. Replace with proper Error variants so the
CLI exits cleanly with a descriptive message instead of crashing.

Also adds a unit test to prove the behavior is intentional.
Copilot AI review requested due to automatic review settings May 2, 2026 08:08
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX May 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves Soroban authorization signing in soroban-cli by replacing todo!() panics for unsupported ScAddress variants with structured Error returns, preventing CLI crashes and providing clearer user-facing failures.

Changes:

  • Added explicit Error variants for unsupported ScAddress types (MuxedAccount, ClaimableBalance, LiquidityPool).
  • Updated sign_soroban_authorizations to return those errors instead of panicking.
  • Added a unit test covering the MuxedAccount unsupported-path behavior.
Comments suppressed due to low confidence (1)

cmd/soroban-cli/src/signer/mod.rs:111

  • The ScAddress::Contract(...) branch returns Error::MissingSignerForAddress even though the comment states contract addresses aren't supported, and there is already an Error::ContractAddressAreNotSupported { .. } variant. This yields a misleading error message ("Missing signing key for account...") for contract addresses. Consider returning ContractAddressAreNotSupported here (or removing that unused variant if it's not intended to be used).
            ScAddress::Contract(stellar_xdr::curr::ContractId(Hash(c))) => {
                // This address is for a contract. This means we're using a custom
                // smart-contract account. Currently the CLI doesn't support that yet.
                return Err(Error::MissingSignerForAddress {
                    address: stellar_strkey::Strkey::Contract(stellar_strkey::Contract(*c))
                        .to_string(),
                });
            }

Comment thread cmd/soroban-cli/src/signer/mod.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

2 participants