Skip to content

id-pg: translator emits ambiguous requests for columns named like PostgREST reserved params (or/select/…) #14391

Done

Description

@dezren39

Evidence (verified on origin/main 1e80e51, crate landed in #13760 / PR 95b052f)

The translator uses the column name verbatim as the PostgREST query-parameter key (pkgs/id/crates/id-pg/src/translate.rs step 10: params.push((leaf.column.clone(), render_leaf_value(leaf)?))), and CollectionAllowlist (allowlist.rs) performs no validation on declared names — any string is an acceptable column/relation name.

Reproduced with a throwaway integration test (removed after verification; cargo test -p id-pg in pkgs/id):

  • Collection declares filterable columns id, or, select; query filters or eq 1 with keyset pagination over id → params:
    [("select", "id,or,select"), ("or", "eq.1"), ("or", "(id.gt.9)"), ("order", "id.asc"), ("limit", "50")]
    Two or params: the column filter and the adapter-generated keyset logic group. PostgREST reserves or/and as the logic operators, so the column predicate is serialized into a position the source reads as boolean logic — the request is at best rejected, at worst misread.
  • Same collection, filter select eq 2, no pagination → params:
    [("select", "id,or,select"), ("select", "eq.2"), …]
    Two select params: the projection and a column filter PostgREST reads as a second projection directive.

Same class, unverified beyond reading: a filter on a column named order/limit/offset lands in a directive position; a relation name containing /, ? or # is interpolated raw into the path (format!("/{relation}")); column names containing ,/(/)/"/whitespace are interpolated raw into the select/order/or values (only in.(…) and keyset cursor values go through quoted_literal; identifiers never do).

This contradicts the crate root's own contract (lib.rs\): malformed-value edges "are refused as field_unsupported` rather than serialized into a request the source would reject or misread") — reserved-name columns serialize instead of refusing.

Why it matters

A column predicate silently promoted into a directive/logic position can widen or break the result set (e.g. a keyset or group merged with a column-or filter), defeating the allowlist's job as the layer-1 grant boundary. The transport slice (#13763) will turn these requests into live HTTP calls; registration (#13758, "checking them against the live endpoint") does not exist yet, so the translator is currently the only guard — and it does not guard this.

Dedupe

Suggested fix shape / acceptance

  • Translator (defense in depth, before any network call): refuse field_unsupported when a filter/order column name collides with a PostgREST reserved parameter (select, order, limit, offset, or, and, plus the Prefer/count family as applicable) or when a relation/column name is not a safe identifier for its syntactic position.
  • Registration (id: impl: Postgres HTTP adapter registration and owner config (from #5805) #13758): reject such names at allowlist construction against the live endpoint.
  • Regression tests in id-pg: filter on or + keyset pagination refuses; filter on select refuses; (existing suite: 22 passed per landing commit).
{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-24T13:51:23Z",
    "session_id": "ses_e5df2327eddffeZ0r1Lz7AVdq4",
    "lane": null,
    "host": "amd",
    "worktree": "/home/user/git/code",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/user/git/code",
      "repo": "developing-today/code",
      "branch": "queue/21642-14039-native-lancedb-reader",
      "sha": "9e6b4adf64e54d8c623c329257bbac3b1f859266"
    },
    "auth_subject": "oc-code-05",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Activity

  1. added
    kind/bug
    task/triage
    source/creator
    priority/normal
    app/id
    effort/s
    on Nov 24, 2026
  2. developing-today commented on Nov 24, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 24, 2026

    @dezren39
    MemberAuthor

    PR #14497 implements the translator refusal: filter/order columns that are reserved PostgREST names (select, order, limit, offset, or, and, not, columns, on_conflict) or not plain identifiers now refuse as field_unsupported; a non-identifier relation collapses to not_available. Projection names and the registration-time check are not covered here, see the follow-up issue linked from #13758.

  4. added a commit that references this issue on Nov 24, 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

    app/ideffort/skind/bugpriority/normalsource/creatorstatus:donetask/triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions