Skip to content

fix(frontend): prevent MultiSelect crash on undefined value#9364

Merged
rubenfiszel merged 1 commit into
mainfrom
ruben/win-1996-for-this-approval-page-user-see-nothing-how-come
May 28, 2026
Merged

fix(frontend): prevent MultiSelect crash on undefined value#9364
rubenfiszel merged 1 commit into
mainfrom
ruben/win-1996-for-this-approval-page-user-see-nothing-how-come

Conversation

@rubenfiszel
Copy link
Copy Markdown
Contributor

@rubenfiszel rubenfiszel commented May 28, 2026

Summary

The approval/resume page (e.g. /approve/{workspace}/{job}?token=...) rendered completely blank for some flows. The production stack trace pointed to value.length === 0 inside MultiSelect.svelte.

Root cause: value is a $bindable() prop with no default, typed Value[], but ArgInput.svelte:862,872 renders <MultiSelect bind:value> even when value == undefined (an enum-array form field with no initial value — exactly the approval form's default_payload case). MultiSelect then dereferenced value.length / value.map / value.filter on undefined, throwing a TypeError that crashed the entire page render → user sees nothing.

Changes

  • frontend/src/lib/components/select/MultiSelect.svelte: introduce let currentValue = $derived(value ?? []) and route every read (.length, .map, .filter, .includes, reorder) through it. Writes still target the bindable value but base off currentValue, so an undefined initial value becomes a real array on first mutation. This follows the AGENTS.md recommended alternative ($derived with nullish coalescing) rather than the banned $bindable(default_value) pattern.

Test plan

  • Open a form (e.g. an approval page or run form) that renders an enum-array argument with no default value via ArgInput, so MultiSelect mounts with value === undefined. Confirm the page renders (placeholder shown, no blank screen / console error).
  • Select an item → it is added. Remove it → placeholder returns. Drag to reorder → order persists.

Note: browser verification could not be run locally — the Playwright browser binary failed to download in this environment (repeated installs report success but produce no chrome executable). Root cause and fix are confirmed from the production minified stack trace (B1qfC2vM.js: _().length===0MultiSelect.svelte:135) and the ArgInput call sites.

Fixes WIN-1996

🤖 Generated with Claude Code


Summary by cubic

Fixes a crash in MultiSelect when value is undefined that caused the approval page to render blank. Reads now use a derived array so the component renders safely and behaves as expected.

  • Bug Fixes
    • Use $derived(value ?? []) as currentValue and route all reads (length, map, filter, includes, reorder) through it.
    • Keep writes targeting the bound value; an undefined initial value becomes an array on first mutation.
    • Resolves blank approval page for enum-array fields without defaults via ArgInput (Fixes WIN-1996).

Written for commit af3a921. Summary will update on new commits.

Review in cubic

MultiSelect read `value.length` directly while `value` is a bindable
prop with no default, so a parent passing `undefined` (e.g. an
enum-array approval form field with no initial value via ArgInput)
threw a TypeError that blanked the entire approval page. Guard all
reads behind a `value ?? []` derived.

Fixes WIN-1996

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rubenfiszel rubenfiszel marked this pull request as ready for review May 28, 2026 14:48
@rubenfiszel rubenfiszel merged commit aea0061 into main May 28, 2026
21 checks passed
@rubenfiszel rubenfiszel deleted the ruben/win-1996-for-this-approval-page-user-see-nothing-how-come branch May 28, 2026 14:48
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant