Skip to content

Prompt workflow actions throw on validation — invalid URL, long note, and suggestion errors surface as the masked digest toast #549

Closed

Description

@gkhngyk

Problem

Three small server actions still throw on user-triggerable validation failures, which in production surfaces as the masked An error occurred in the Server Components render… digest: … string instead of the real message.

In web/src/lib/actions/prompt-workflow.ts:

  1. addPromptTargetUrl throws Enter a valid URL, This URL is already targeted for this prompt (unique-violation), and DB errors. Repro: type abc in the target-URL input on a prompt detail page and press Enter (the input submits on Enter) — the toast shows the digest string.
  2. addPromptNote throws Note cannot be empty and Note is too long (max 2000 characters). A >2000-char note is rejected with a digest toast and the typed note is lost — the textarea has no maxLength or character counter to warn the user first.

In web/src/lib/actions/prompt-suggestions.ts:

  1. acceptSuggestion throws Suggestion not found or already processed and No prompt set exists for this brand. Create one first. — the latter is reachable right after brand creation and tells the user exactly how to proceed, but it never reaches them.

Call sites: web/src/app/[locale]/(dashboard)/dashboard/prompts/[id]/_workflow-cards.tsx and web/src/app/[locale]/(dashboard)/dashboard/prompts/_suggestions-card.tsx.

Fix

Follow the PR #536 pattern (addPromptToBrand in web/src/lib/actions/prompt.ts is the reference implementation): return { …value } | { error: string } instead of throwing, and branch on 'error' in result at the call sites.

  • Render the addPromptTargetUrl error as inline red helper text under the URL input rather than a toast.
  • Bonus for addPromptNote: add maxLength={2000} plus a small character counter to the textarea so users are warned before submitting.

Acceptance

  • Entering abc as a target URL shows Enter a valid URL inline.
  • A >2000-char note shows the length message (and the counter warns beforehand).
  • Accepting a suggestion on a brand without a prompt set shows the "Create one first" message.

Activity

  1. added
    bug
    good first issue
    on Jul 28, 2026
  2. BharadwajKanneveti commented on Jul 31, 2026

    @BharadwajKanneveti
    Contributor

    Hi @gkhngyk can I work on this issue

  3. gkhngyk commented on Aug 1, 2026

    @gkhngyk
    ContributorAuthor

    Assigned to you — thanks! 🙌 Heads-up: a fix for the sibling issue #547 (addPromptToSet) is about to land, which changes its return shape to { prompt } | { error, code? }. Worth branching from main after that merges so the two don't conflict.

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

Metadata

Metadata

Labels

buggood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions