Skip to content

improvement(tables): make max row size env-configurable and raise default to 400KB#5338

Merged
TheodoreSpeaks merged 1 commit into
stagingfrom
debug/table-row
Jul 1, 2026
Merged

improvement(tables): make max row size env-configurable and raise default to 400KB#5338
TheodoreSpeaks merged 1 commit into
stagingfrom
debug/table-row

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • raise the table row size limit default from 100KB to 400KB
  • make it overridable via a new TABLE_MAX_ROW_SIZE_BYTES env var (read at call time in validateRowSize, same pattern as the plan-limit overrides)
  • error message now reports the effective limit instead of the hardcoded constant

Type of Change

  • Improvement

Testing

Table validation tests pass (54/54). bun run lint and bun run check:api-validation:strict pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 1, 2026 10:59pm

Request Review

@cursor

cursor Bot commented Jul 1, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Larger default rows increase per-request memory and stored JSONB size; mis-set env overrides could weaken or tighten limits in production, but scope is limited to table row validation.

Overview
Raises the default per-row serialized size cap for user tables from 100KB to 400KB and makes the limit overridable via server env TABLE_MAX_ROW_SIZE_BYTES (documented default 409600), aligned with other table plan-limit env knobs.

Adds getMaxRowSizeBytes() (env read at call time through envNumber) and wires validateRowSize to use the effective limit so validation errors report the active cap instead of a hardcoded constant.

Reviewed by Cursor Bugbot for commit a34c919. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Raises the per-row size limit from 100 KB to 400 KB and makes it runtime-configurable via TABLE_MAX_ROW_SIZE_BYTES, following the same envNumber pattern used for plan-tier row/table count limits. The error message now reports the effective limit rather than the old hard-coded constant.

  • constants.ts promotes MAX_ROW_SIZE_BYTES to 400 KB and adds getMaxRowSizeBytes(), which reads the env var at call time with a min:1, integer:true guard.
  • validation.ts replaces the direct constant reference with getMaxRowSizeBytes() and propagates the resolved value into the error string.
  • env.ts registers the new optional numeric env var in the schema alongside the existing table plan-limit overrides.

Confidence Score: 4/5

Safe to merge; the logic change is confined to a single validation function and follows the well-established env-override pattern already in use.

The production code path is clean — getMaxRowSizeBytes() correctly defaults to the new 400 KB constant and safely gates on min:1, integer:true. The one concern is in the test: it sizes its oversized payload against the static constant rather than the runtime-resolved value, so the assertion could silently pass if TABLE_MAX_ROW_SIZE_BYTES were set to a larger value in the test environment.

The test at apps/sim/lib/table/tests/validation.test.ts line 176 should drive off getMaxRowSizeBytes() rather than TABLE_LIMITS.MAX_ROW_SIZE_BYTES.

Important Files Changed

Filename Overview
apps/sim/lib/core/config/env.ts Adds TABLE_MAX_ROW_SIZE_BYTES as an optional numeric env var following the existing pattern for table plan limit overrides.
apps/sim/lib/table/constants.ts Raises MAX_ROW_SIZE_BYTES default from 100 KB to 400 KB and introduces getMaxRowSizeBytes() that reads the env override via envNumber with a min:1, integer:true guard.
apps/sim/lib/table/validation.ts Swaps the hard-coded constant for getMaxRowSizeBytes() and threads the effective limit into the error message; no logic change beyond that.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[validateRowSize called] --> B[getMaxRowSizeBytes]
    B --> C{TABLE_MAX_ROW_SIZE_BYTES env var set?}
    C -- Yes --> D[envNumber validates min=1, integer=true]
    D --> E[Use env value]
    C -- No --> F[Use TABLE_LIMITS.MAX_ROW_SIZE_BYTES 400 KB default]
    E --> G[Compute JSON.stringify size]
    F --> G
    G --> H{size > maxRowSizeBytes?}
    H -- Yes --> I[Return error with effective limit in message]
    H -- No --> J[Return valid]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[validateRowSize called] --> B[getMaxRowSizeBytes]
    B --> C{TABLE_MAX_ROW_SIZE_BYTES env var set?}
    C -- Yes --> D[envNumber validates min=1, integer=true]
    D --> E[Use env value]
    C -- No --> F[Use TABLE_LIMITS.MAX_ROW_SIZE_BYTES 400 KB default]
    E --> G[Compute JSON.stringify size]
    F --> G
    G --> H{size > maxRowSizeBytes?}
    H -- Yes --> I[Return error with effective limit in message]
    H -- No --> J[Return valid]
Loading

Reviews (1): Last reviewed commit: "improvement(tables): make max row size e..." | Re-trigger Greptile

@TheodoreSpeaks TheodoreSpeaks merged commit 4421512 into staging Jul 1, 2026
17 checks passed
@TheodoreSpeaks TheodoreSpeaks deleted the debug/table-row branch July 1, 2026 23:10
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.

1 participant