Skip to content

fix(web): return addPromptToSet failures as values instead of throwing - #580

Merged
gkhngyk merged 1 commit into
mainfrom
fix/add-prompt-to-set-error-values
Aug 3, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/add-prompt-to-set-error-values

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

addPromptToSet still threw on user-reachable failures, so in production the plan-limit and validation messages surfaced as the masked An error occurred in the Server Components render… digest toast. This converts it to the same value-shape savePromptSet adopted in #536:

  • addPromptToSet now returns { prompt } | { error, code?: 'plan_limit' }; all four throw sites became values ("Prompt set not found", PlanLimitError → code: 'plan_limit', empty platform/model selection, Supabase insert errors).
  • Callers beyond the two named in the issue were adapted too: addPromptToBrand and trackFanoutQuery drop their try/catch wrappers and forward the error value; acceptSuggestion keeps its existing throwing contract, adapted to the new shape.
  • The brand Prompts page (bulk suggestion save + manual add) shows the real message via toast; the bulk path also refreshes the list when a parallel save partially fails, so prompts that did land appear.

Related issue

Closes #547

Type of change

  • fix — Bug fix

How to test

  1. On an org at its prompt cap, open Brand → Prompts and add a single prompt — the toast shows the human-readable plan-limit message, never the digest string.
  2. Same at the bulk "Save prompts" flow for generated suggestions.
  3. Deselect all platforms and models on the manual add card — the toast reads "At least one platform or model must be selected."
  4. Fan-out "Track" and suggestion "Accept" flows still work end to end.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Production masks errors thrown from server actions, so plan-limit and
validation failures from addPromptToSet reached users as the meaningless
digest toast (#427 pattern). Convert it to the same
{ prompt } | { error, code? } shape savePromptSet adopted in #536:

- addPromptToSet returns { prompt } | { error, code?: 'plan_limit' };
  PlanLimitError from enforceLimit maps to code 'plan_limit'
- addPromptToBrand and trackFanoutQuery drop their try/catch wrappers and
  forward the error value
- acceptSuggestion keeps its existing throwing contract, adapted to the
  new shape
- brand Prompts page (bulk suggestion save + manual add) shows the real
  message via toast; the bulk path also refreshes the list on partial
  failure so saved prompts appear

Closes #547
@gkhngyk
gkhngyk merged commit 3c9c214 into main Aug 3, 2026
5 checks passed
@gkhngyk
gkhngyk deleted the fix/add-prompt-to-set-error-values branch August 3, 2026 00: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.

addPromptToSet still throws — plan-limit and validation errors surface as the masked digest toast

1 participant