Repository navigation
fix(runtime): tier 2 Postgres calls honor the argument size limit - #693
Merged
Merged
Conversation
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
force-pushed
the
fix/663-gateway-postgres-bytes
branch
from
October 15, 2026 20:24
d30e6af to
1ccd521
Compare
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
runtimeBodyLimitIdalready mapspostgres.*toruntime.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 sametoo_large(413), carryingscope,limitIdandvalue, 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, apostgres/warehouseconnection inserted into the local instance's database (the connector refuses private addresses, andpatchy devreads fixtures anyway), then a tier 2 patch with an action that runsSELECT length($1::text)with a text parameter of N characters, called from the page underpatchy 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
docs/limits.md,docs/API.md,docs/product.mdand thepatchy-postgresskill already state the 256 KiB cap with no tier carve-out; the code now matches them.patchy devuses the same gateway, so it enforces the cap too (shown above). No runner changes.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.