Skip to content

Bug: disabling the moderation provider throws an uncaught saveGovernancePolicy ConvexError — endpoint URL is validated even when enabled:false #2657

Closed

Description

@yannickmonney

Problem

Toggling Governance → Guardrails → Moderation provider OFF (after it was enabled but never given an endpoint) fires an uncaught server-side ConvexError — the save validates the endpoint URL / request template even though the provider is being disabled. The UI ends in the correct state (switch off) and shows no toast, so it's console-only, but it's an uncaught Server Error of exactly the class the repo has been sweeping (#2062, #2344, the raw-Error batch).

Distinct from closed #2344, which fixed the enable path (now shows a graceful "Set an endpoint first" inline notice, verified working) — this is the disable path validating config it should ignore.

Current behaviour

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

  1. Governance → Guardrails → toggle Enable moderation provider ON → inline notice "enabling won't persist until it's configured" (good), config UI revealed, nothing persisted.
  2. Toggle it back OFF.
  3. Console logs an uncaught error (no user-visible toast; switch correctly shows off; no config file written):
[CONVEX A(governance/file_actions:saveGovernancePolicy)] Uncaught ConvexError:
{"code":"validation","message":"Invalid moderation_provider configuration: [
  { path:["endpoint","url"], message:"Invalid URL" },
  { path:["endpoint","url"], message:"URL must be http(s)://" },
  { path:["endpoint","requestTemplate"], message:"Too small: expected string to have >=1 characters" },
  { path:["endpoint","requestTemplate"], message:"Request template must be valid JSON" } ]"}
  at handler (../../convex/governance/file_actions.ts:175:8)

Expected

Disabling a guardrail layer (enabled: false) should not validate the endpoint/template fields — you're turning it off. No server error on disable.

Code pointers

  • convex/governance/file_actions.ts:175 — saveGovernancePolicy handler (validation runs regardless of enabled)
  • lib/shared/schemas/governance.ts — moderation_provider schema (gate endpoint validation on enabled === true)

Acceptance criteria

  • Disabling the moderation provider persists enabled:false with no ConvexError
  • Endpoint/template validation applies only when enabled: true
  • Regression test covers enable-without-endpoint → disable

Related: #2344 (enable path, fixed), #2062 (governance raw-error sweep).

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: lowservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions