Skip to content

Bug: Governance feature-control "Max context tokens" below 4096 saves as a silent false-success (optimistic row, dialog closes, nothing persists, raw ConvexError in console) #2660

Closed

Description

@yannickmonney

Problem

The Feature-controls rule editor (Governance → Policies & Limits) lets you enter a Max context tokens value below the server's 4096 floor. The client Input has no lower bound, so on Confirm the dialog closes, the rule row optimistically appears with the entered value — but the server rejects it with an uncaught ConvexError (validation), nothing persists, and on reload the rule is gone. The user believes they set a token cap; they didn't, and the only signal was a console error.

Current behaviour

Verified live (2026-07-11, main @ 94ef84e):

  1. Settings → Governance → Policies & Limits → Feature controls → Add rule.
  2. Type 1000 in Max context tokens → Confirm.
  3. Dialog closes; the rule row shows "default / All users / ✔✔✔ / 1,000" as if saved. Console logs:
    [CONVEX A(governance/file_actions:saveGovernancePolicy)] Uncaught ConvexError:
    {"code":"validation","message":"Invalid feature_flags configuration: [ … maxContextTokens … "Too small: expected number to be >=4096" ]"}
    at handler (../../convex/governance/file_actions.ts:175:8)
    
  4. Reload → "No feature control rules configured." The rule never persisted; no user-visible error at any point.

Code pointers

  • app/features/settings/governance/components/feature-flags-editor.tsx — Max-context-tokens Input has min={0} (no 4096 floor); handleSubmit has no client validation; save-error path surfaces error.message raw
  • lib/shared/schemas/governance.ts:352 — maxContextTokens: z.number().min(4096).optional() (server floor)
  • convex/governance/file_actions.ts:175 — saveGovernancePolicy throws the validation ConvexError

Proposed change

Enforce the 4096 floor client-side inline (like budget-editor's validateBudgetRule), keep Confirm disabled with a field error until valid, and don't optimistically render an unsaved rule. Route the save error through mapGovernanceSaveError so a rejection is visible and localized.

Acceptance criteria

  • A sub-4096 value is blocked inline with a localized field error; Confirm stays disabled
  • No optimistic row appears for a rejected save; no uncaught ConvexError
  • The quick-set buttons (8K–128K) still work

Related: #2061 (closed — budget-rule dialog validation parity), #2062 (closed — governance raw-error toasts).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: mediumservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions