Skip to content

feat(table): make plan table limits configurable via env vars#4406

Merged
waleedlatif1 merged 7 commits intostagingfrom
waleedlatif1/table-limit-envvars
May 2, 2026
Merged

feat(table): make plan table limits configurable via env vars#4406
waleedlatif1 merged 7 commits intostagingfrom
waleedlatif1/table-limit-envvars

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Add per-tier env var overrides for table count and row caps: FREE_/PRO_/TEAM_/ENTERPRISE_TABLES_LIMIT and *_TABLE_ROWS_LIMIT
  • Hosted defaults unchanged — fallbacks point at the existing literal values (3/1000, 25/5000, 100/10000, 10000/1000000) when no env var is set
  • Self-hosted deployments with billing disabled fall through to the free tier, so setting these vars lifts the cap without code changes
  • Wire the new vars into helm/sim/values.yaml alongside the existing per-tier EXECUTION_TIMEOUT_* block

Type of Change

  • Improvement

Testing

Tested manually

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
Copy link
Copy Markdown

vercel Bot commented May 2, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 2, 2026 6:30pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 2, 2026

PR Summary

Medium Risk
Adds new env-driven configuration paths for table feature caps and also changes how several billing/KB runtime numeric settings are parsed, which could alter limits/timeouts/concurrency if env values are malformed or previously relied on JS coercion.

Overview
Table plan limits are now configurable via env vars. apps/sim/lib/table/constants.ts introduces getTablePlanLimits() which applies FREE_/PRO_/TEAM_/ENTERPRISE_TABLES_LIMIT and *_TABLE_ROWS_LIMIT overrides on top of existing defaults, and table/billing.ts now uses this dynamic lookup instead of a static constant.

Numeric env overrides are normalized across the app. envNumber() is added to lib/core/config/env.ts (and the testing env mock) and is adopted in knowledge processing (Trigger.dev task config, document processing/embedding concurrency, delays/timeouts), copilot stream TTL/event limits (with min: 1), and billing thresholds/plan cost limits; Helm values add the new table-limit variables.

Reviewed by Cursor Bugbot for commit 643724e. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 2, 2026

Greptile Summary

This PR makes per-tier table count and row-limit caps configurable via env vars, introduces a shared envNumber helper that fixes the implicit string-coercion issue present across all existing || fallback patterns, and wires the new vars into the Helm chart. The implementation is clean — env vars are declared in env.ts, read through envNumber, and all previous consumers of the static TABLE_PLAN_LIMITS have been migrated to getTablePlanLimits().

Confidence Score: 5/5

Safe to merge — no P0/P1 findings; only two minor P2 suggestions.

All changes are additive and backwards-compatible. The envNumber helper is well-tested via the mock, existing behaviour is preserved when env vars are absent, and the removed TABLE_PLAN_LIMITS export has no remaining consumers.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/core/config/env.ts Adds 8 new optional table-limit env vars and exports the envNumber helper for safe string→number coercion with a configurable minimum threshold.
apps/sim/lib/table/constants.ts Renames static TABLE_PLAN_LIMITS to DEFAULT_TABLE_PLAN_LIMITS and adds getTablePlanLimits() which overlays env var overrides; no remaining consumers of the old export.
apps/sim/lib/table/billing.ts Updated to call getTablePlanLimits() at the top of getWorkspaceTableLimits(), correctly picking up env-overridden limits for every plan resolution path including error fallbacks.
helm/sim/values.yaml Adds 8 table-limit env vars with the same default values as the code constants, enabling operators to override them per-deployment without code changes.
packages/testing/src/mocks/env.mock.ts Adds envNumber to the env mock, duplicating the production implementation verbatim — keeps tests working but means two copies of the logic need to stay in sync.
apps/sim/lib/copilot/request/session/buffer.ts Removes the local parsePositiveNumber helper and replaces it with envNumber(..., { min: 1 }), unifying the coercion pattern.
apps/sim/lib/billing/subscriptions/utils.ts Replaces `
apps/sim/background/knowledge-processing.ts Replaces `

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[getWorkspaceTableLimits workspaceId] --> B[getTablePlanLimits]
    B --> C{env var set?}
    C -- yes --> D[envNumber coerces string to number]
    C -- no --> E[DEFAULT_TABLE_PLAN_LIMITS fallback]
    D --> F[planLimits map]
    E --> F
    A --> G[getWorkspaceBilledAccountUserId]
    G -- no account --> H[planLimits.free]
    G -- has account --> I[getHighestPrioritySubscription]
    I --> J[getPlanTypeForLimits]
    J --> K{planLimits plan}
    K -- found --> L[Return tier limits]
    K -- not found --> H
    A -- error --> H
Loading

Reviews (4): Last reviewed commit: "fix(env): add min option to envNumber fo..." | Re-trigger Greptile

Comment thread apps/sim/lib/table/constants.ts
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/knowledge/documents/service.ts
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/copilot/request/session/buffer.ts Outdated
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 643724e. Configure here.

@waleedlatif1 waleedlatif1 merged commit 879dab9 into staging May 2, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/table-limit-envvars branch May 2, 2026 18:43
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