Skip to content

fix(runtime): tier 2 Postgres calls honor the argument size limit - #693

Merged
allisonmahmood merged 1 commit into
mainfrom
fix/663-gateway-postgres-bytes
Oct 15, 2026
Merged

allisonmahmood merged 1 commit into
mainfrom
fix/663-gateway-postgres-bytes

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

Problem

runtime.postgres.bytes (256 KiB) caps a Postgres operation's arguments, such as a raw query's SQL and parameters. Tier 1 enforces it, but tier 2 handlers reach Postgres through the callback gateway, which only checked PostHog's equivalent cap. A tier 2 action could send Postgres arguments past the documented limit, bounded only by the gateway's general per-call byte budget.

Fix

The gateway's argument check now covers both integrations: runtimeBodyLimitId already maps postgres.* to runtime.postgres.bytes, so the PostHog check became an integration check that picks the matching cap. It measures the same encoded { op, args }, sits in the same place (after the kind and operation checks, before anything runs or is journaled) and refuses with the same too_large (413), carrying scope, limitId and value, attributed to the operation.

One gateway test sits at the boundary: arguments of exactly 262,144 bytes run, one byte more is refused and the handler never runs. Without the fix it fails (the over-cap call returns ok: true).

Tested by hand

pnpm dev up team, a postgres/warehouse connection inserted into the local instance's database (the connector refuses private addresses, and patchy dev reads fixtures anyway), then a tier 2 patch with an action that runs SELECT length($1::text) with a text parameter of N characters, called from the page under patchy dev. The installed dev runtime was built from this branch. What the action returned:

{
  "under": { "ok": true, "n": 200000 },
  "over": {
    "ok": false,
    "name": "PatchyError",
    "code": "too_large",
    "scope": "viewer",
    "limitId": "runtime.postgres.bytes",
    "value": 262144,
    "operation": "postgres.query",
    "message": "Invocation callback exceeds runtime.postgres.bytes."
  }
}

Surfaces

  • Wire contract, docs, skills: none needed. docs/limits.md, docs/API.md, docs/product.md and the patchy-postgres skill already state the 256 KiB cap with no tier carve-out; the code now matches them.
  • Dev loop: patchy dev uses the same gateway, so it enforces the cap too (shown above). No runner changes.
  • Migrations, CLI, served pages, vocabulary: not touched.

Left as it is: tier 1 refuses an oversized integration call inside its logged path, so it appears in the connection's recent calls; tier 2 refuses before the journal row, as the PostHog check already did. The refusal is still recorded on the invocation with its operation. Changing that would touch both integrations and is not this issue.

Closes #663

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

@github-actions github-actions Bot added area:server Touches the server area size:s Under 100 changed lines labels Oct 15, 2026
The callback gateway capped PostHog arguments at runtime.posthog.bytes but
let postgres.* callbacks through unchecked, so a tier 2 action could send
Postgres arguments past runtime.postgres.bytes, which tier 1 refuses. The
gateway now applies each integration's own cap and refuses with the same
too_large refusal tier 1 gives.

Closes #663

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the fix/663-gateway-postgres-bytes branch from d30e6af to 1ccd521 Compare October 15, 2026 20:24
@allisonmahmood
allisonmahmood merged commit 7662566 into main Oct 15, 2026
13 checks passed
@allisonmahmood
allisonmahmood deleted the fix/663-gateway-postgres-bytes branch October 15, 2026 20:34
allisonmahmood added a commit that referenced this pull request Oct 16, 2026
…u when they fail (#720)

Release 13's What's new entry, written from `c9b8fc4`, ahead of
deploying it. `patchy` and `CURRENT_RELEASE` move to `0.13.0`, so CLIs
and patch repos installed before this deploy are told to upgrade.

| Change | PRs |
| --- | --- |
| New: Home puts the patches you use first | #713, #716, #719 |
| New: Every patch in one list | #715 |
| Improved: Each patch's page leads with Open | #717 |
| New: See when your tools are failing | #718 |
| Fixed: Everyone has a name | #687 |
| Improved: Your company's look is easier to get right | #697, #696,
#703, #688 |
| Improved: Forms follow your look's error states | #691, #692 |
| Improved: Clearer answers when a publish goes wrong | #686, #685, #689
|
| Fixed: Your agent's Patchy commands are steadier | #695, #704, #680,
#681 |
| Behind the scenes: stricter checks on static pages and tools' database
requests; malformed requests are logged | #682, #693, #683 |
| Behind the scenes: usage numbers count every publish, sharing change
and restore | #698, #699, #700, #690 |
| Test and tooling only, no line | #705, #702, #701, #694, #684, #607 |

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:server Touches the server area size:s Under 100 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(runtime): tier 2 Postgres calls skip the Postgres argument size limit

1 participant