Skip to content

rs-sdk-ffi: where_json has no identifier value type — a $ownerId / $id filter is compared as text and silently matches nothing #4822

Open

Description

@romchornyi

Expected Behavior

A where_json clause on an identifier-valued field — the system fields $ownerId and $id, or
any document property the contract types as byteArray/contentMediaType: application/x.dash.dpp.identifier
— matches the documents holding that identifier. A clause that cannot be evaluated is rejected,
rather than answered with an empty result.

Current Behavior

dash_sdk_document_search (and the aggregate query paths) parse where_json values with
json_to_platform_value, which maps every JSON string to Value::Text:

There is no way to express an identifier value: base58 text stays Value::Text, and the query
is built against an identifier-typed field with a text operand. Drive accepts it, evaluates it,
and returns zero rows with no error — so a caller cannot tell "no such document" from "this
filter can never match".

Verified on testnet against the identityVerify contract
(Bhptm3yBDhLkRNt7ofjpwaBHhMUKjDrQoPufKzQaxmpK, document type identityVerify), where a
document was known to exist:

where result
[["normalizedLabel","==","<label>"]] the document
[["$ownerId","==","<base58>"],["normalizedLabel","==","<label>"]] 0 documents, grpc-status: 0
[["$ownerId","==","<base58>"],["normalizedParentDomainName","==","dash"],["normalizedLabel","==","<label>"]] 0 documents, grpc-status: 0

The contract's indices cover the second and third shapes (ownerId,
ownerId_NormDomainName_NormLabel), so the empty result is the value comparison, not a missing
index.

Possible Solution

In json_to_platform_value, resolve the value against the field being compared instead of the
JSON type alone:

  • for $ownerId and $id, decode the string as base58 into Value::Identifier;
  • for a document property the contract types as an identifier, do the same, using the document
    type already in hand when the clause is built;
  • when a string cannot be decoded for an identifier-typed field, return an error rather than
    passing text through — an unmatchable query should fail loudly, which is what makes this class
    of bug diagnosable.

Accepting an explicit form ({"base58": "..."} or a JSON array of 32 bytes) would work too, but
callers today write plain base58 strings, which is also what every other SDK surface returns for
these fields.

Both parsers need the change; sum.rs and average.rs route through build_base_query and
inherit it.

Steps to Reproduce (for bugs)

  1. Publish any document whose contract indexes $ownerId.
  2. Query it through dash_sdk_document_search with
    where_json = [["$ownerId","==","<owner base58>"]].
  3. Observe an empty documents array and no error.
  4. Repeat without the $ownerId clause — the document is returned.

The table above is the same check run over gRPC-web against an ENABLED testnet Evo node
(org.dash.platform.dapi.v0.Platform/getDocuments), independent of the FFI.

Context

Two call sites in dashpay/dashwallet-ios were written against this shape and both failed
silently:

  • the username proof-of-identity lookup — a published identityVerify link never appeared on
    the request-details screen, because the query filtered by $ownerId and always came back
    empty;
  • the DashConnect login-key response lookup, where the always-empty result makes a
    create-or-replace decision always choose create, and stops the post-failure race recovery from
    ever finding the document (filed as a separate issue on that repo).

Both were fixed app-side by dropping the $ownerId clause and checking ownership on the
returned document, but the FFI will keep offering the same trap: the query looks right, is
accepted, and answers with an empty set.

Your Environment

Activity

  1. added
    bug
    on Sep 18, 2026
  2. romchornyi commented on Sep 18, 2026

    @romchornyi
    ContributorAuthor

    App-side companion issue, with the two call sites that hit this: dashpay/dashwallet-ios#1137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions