Skip to content

fix(id-pg): refuse reserved or non-identifier filter/order fields (#14391) - #14497

Merged
dezren39 merged 1 commit into
mainfrom
dispatch/23601-14391-id-pg-reserved-fields
Nov 24, 2026
Merged

dezren39 merged 1 commit into
mainfrom
dispatch/23601-14391-id-pg-reserved-fields

Conversation

@dezren39

@dezren39 dezren39 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Closes #14391.

What

pkgs/id/crates/id-pg/src/translate.rs emitted the filter/order column name verbatim as a PostgREST query-parameter key, and interpolated the relation name raw into the request path. A column named or, select, limit, ... collided with a directive/logic parameter (or doubled with the keyset group, select doubled the projection); a name containing ,/()/whitespace was rendered raw.

Change

  • allowlist.rs: adds RESERVED_PARAM_NAMES (select, order, limit, offset, or, and, not, columns, on_conflict), is_plain_identifier(name), and is_usable_field_name(name).
  • translate.rs step 7/8: a relation that is not a plain identifier collapses to not_available (same collapse rule as an unlisted relation); a filter or order column that is reserved or not a plain identifier is refused as field_unsupported, before step 10 renders any parameter.

Order of refusals is otherwise unchanged, and the refusal bodies stay functions of code + feature name only (no new disclosure channel).

Tests

New unit tests in translate.rs: filter on or/select refused, order on limit refused, filter on a,b refused, relation items/x → not_available, and a plain column still translates. Full crate suite: cargo test -p id-pg — 10 unit + 2 property + 15 refusal-table tests pass.

Note: cargo clippy -p id-pg in this worktree fails before my code with E0514 found crate serde compiled by an incompatible version of rustc (toolchain/dep cache mismatch in the worktree), so clippy was not run clean here; cargo test and cargo fmt are clean.

Confidence: high, low-risk (refusals only — no previously successful request shape changes except the now-refused collision cases).

{
  "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-24T17:11:00Z",
    "session_id": "ses_e5df177e305ffeUZzwUyoH6CdK",
    "lane": null,
    "host": "amd",
    "worktree": "/home/user/git/fleet/dispatch-code-23601",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/user/git/fleet/dispatch-code-23601",
      "repo": "developing-today/code",
      "branch": "dispatch/23601-14391-id-pg-reserved-fields",
      "sha": "dedd4e503b7855d9d4fbbdddd4e1580cb2304945"
    },
    "auth_subject": "oc-code-03",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…4391)

Filter and order columns are emitted as PostgREST query-parameter keys.
A column named or/select/limit/... collided with a directive or logic
parameter, and a non-identifier column or relation name was interpolated
raw. Refuse these as field_unsupported (columns) or not_available
(relation), before any request exists.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 47373ea5-67f9-4c75-968c-318821935053
Commits

Reviewing files that changed from the base of the PR and between a05815e and dedd4e5.

Files selected for processing: 2

  • pkgs/id/crates/id-pg/src/allowlist.rs
  • pkgs/id/crates/id-pg/src/translate.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant