Skip to content

Bug: knowledge_entries mutations throw raw Error instead of ConvexError — opaque Server Errors on client #2000

Description

@yannickmonney

Area

services/platform/convex/knowledge_entries/ — public mutations (createKnowledgeEntry, updateKnowledgeEntry, deleteKnowledgeEntry) and their shared helper (validateTopicAndContent).

Steps to reproduce

  1. Open the Knowledge Entries UI.
  2. Try to create a knowledge entry with an empty topic (or content exceeding the max length), or with a topic that already exists.
  3. Observe the browser console — a raw "Server Error" is surfaced instead of a structured, readable error.

Alternatively:

  • Edit a superseded (non-active) entry.
  • Delete a knowledge entry that no longer exists.

Expected

The client receives a ConvexError with a structured code field (following the pattern used in tasks/mutations.ts and branding/file_actions.ts) so the UI can display a user-readable message.

Actual

throw new Error(...) is used throughout, which Convex surfaces as an opaque "Server Error" in the browser console; the message is lost to the client.

Evidence

services/platform/convex/knowledge_entries/helpers.ts:46throw new Error('Topic is required')
services/platform/convex/knowledge_entries/helpers.ts:48throw new Error(\Topic exceeds ${TOPIC_MAX_LENGTH} characters`) services/platform/convex/knowledge_entries/helpers.ts:50throw new Error('Content is required') services/platform/convex/knowledge_entries/helpers.ts:52throw new Error(`Content exceeds ${CONTENT_MAX_LENGTH} characters`) services/platform/convex/knowledge_entries/mutations.ts:34throw new Error('Unauthenticated')(createKnowledgeEntry)services/platform/convex/knowledge_entries/mutations.ts:53throw new Error(`A knowledge entry for the topic "..." already exists...`) services/platform/convex/knowledge_entries/mutations.ts:86throw new Error('Unauthenticated')(updateKnowledgeEntry)services/platform/convex/knowledge_entries/mutations.ts:90throw new Error('Knowledge entry not found') services/platform/convex/knowledge_entries/mutations.ts:93throw new Error('Only the active version of an entry can be edited') services/platform/convex/knowledge_entries/mutations.ts:116throw new Error(`A knowledge entry for the topic "..." already exists.`) services/platform/convex/knowledge_entries/mutations.ts:172throw new Error('Unauthenticated')(deleteKnowledgeEntry)services/platform/convex/knowledge_entries/mutations.ts:176throw new Error('Knowledge entry not found')` (deleteKnowledgeEntry)

Notes

Related: #1993 (same pattern in websites/customers/vendors). The fix is to import ConvexError from "convex/values" and replace each throw with throw new ConvexError({ code: '...' }) matching the structured pattern used in tasks/mutations.ts. validateTopicAndContent in helpers.ts is called from both public mutations and internal mutations; switching it to ConvexError is safe since ConvexError propagates correctly through both paths.

Severity: medium — user-facing validation and auth errors silently become opaque "Server Error" in the console; the UI typically shows no feedback when these mutations reject.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions