Skip to content

refactor(sdk): validate document requests in one versioned step before sending #5618

Open

Description

@shumkov

Problem

A document request (GetDocuments and the count, sum and average document queries) is checked by three separate layers before it is sent:

  1. the versioned encoder TryFromPlatformVersioned<DocumentQuery> for GetDocumentsRequest (packages/dash-platform-queries/src/documents/document_query.rs), which gates grammar (contains/containsAny, timeRange/integerRange, composite shapes) by the SDK's stored protocol version;
  2. FromProof::check_request per result type (fix(sdk): check document query shapes before sending them #5558), which checks the shape the result view can verify;
  3. the protocol gate needs_protocol_version (fix(sdk)!: refuse requests the network cannot serve yet instead of banning nodes #5561, packages/rs-dapi-client/src/transport/grpc.rs), which checks the network-proven version against a hard-coded 14.

They use different version bases, literals instead of the platform version tables, and leave gaps.

Goal

One versioned "build the request for this result type" step that takes the network-proven version, checks the shape and the version-dependent features from the version tables (not literals), and is the only source of truth. needs_protocol_version stays only for non-document requests (new RPCs, the shielded token_id).

Fold in

  • Covering-index resolution (resolve_{ranked,having}_query_for_mode) runs only after the answer; check it before sending.
  • A single Document::fetch turns "expected 1 element" into a retryable Error::Proof; it should be non-retryable.
  • delegate_from_proof_variant! does not forward check_request.
  • A composite or chained query using contains/containsAny on an SDK seeded at protocol 13 is refused by the encoder's grammar check before the gate can probe the network.
  • Documents::check_request does not reject group_by/having; check_count/sum/average_request ignore pending time and integer range windows (raised in review of chore: merge v5.0-dev into v5.1-dev (5.0.1) #5608).
  • Decide whether Sdk::fetch_moderation_charters_contract's own "is 14 usable" check and the version_for_requests ratchet belong here.

A design spec is being written first; the implementation follows once it is agreed.

Activity

  1. added this to the v5.1.0 milestone on Oct 28, 2026
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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions