Skip to content

fix(models): LedgerEntry::DepositPreauth conflates (None,None) and (Some,Some) validation errors #333

Description

@e-desouza

Problem

src/models/requests/ledger_entry.rs — the DepositPreauth request selector's get_errors() implementation uses a single ExpectedOneOf error for two distinct invalid states:

match (&self.authorized, &self.authorized_credentials) {
    (Some(_), Some(_)) | (None, None) => Err(XRPLModelException::ExpectedOneOf(
        ["authorized", "authorized_credentials"].as_ref(),
    )),
    _ => Ok(()),
}

Both the too-many-fields case (Some, Some) and the no-fields case (None, None) return the same ExpectedOneOf error. Callers that programmatically inspect the error cannot distinguish between them, which forces them to apply the wrong remediation:

  • (None, None) → user should add a field
  • (Some, Some) → user should remove a field

Expected behaviour

Return distinct error variants:

  • (Some, Some)XRPLModelException::ValueEqualsValue (or a dedicated "mutually exclusive fields" variant)
  • (None, None)XRPLModelException::ExpectedOneOf (correct current use)

Affected code

  • src/models/requests/ledger_entry.rsDepositPreauth.get_errors()
  • Same pattern exists in src/models/ledger/objects/deposit_preauth.rs at the ledger object level

Notes

Found during code review of PR #154 (XLS-70 Credentials support). No functional regression in PR #154 — the issue pre-existed and was not introduced by that PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions