Fix duplicate sandbox name validation error display#4519
Conversation
The validation error on the sandbox create/edit modal was duplicated because both `validate_required([:raw_name])` and `validate_required([:name])` added "can't be blank" errors to their respective fields, and then `copy_error(:name, :raw_name)` copied the `:name` error onto `:raw_name` — resulting in two identical errors. Pass `overwrite: false` to `copy_error` so it skips copying when `:raw_name` already carries its own error. https://claude.ai/code/session_01UJyPo9Uz83JMKQ2hCg97XC
Code Review: Fix sandbox name validation appearing twice (#4490)OverviewOne-line fix to prevent duplicate validation errors on the sandbox create/edit modal. When a user leaves the sandbox name blank, "can't be blank" was shown twice because both Code Quality & Correctness
Test — The assertion counting occurrences of Potential ConcernThere are 6 other
This isn't blocking since the issue specifically reports the sandbox modal, but it's worth a follow-up. VerdictThe fix is correct, focused, and well-tested. Ship it. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4519 +/- ##
==========================================
+ Coverage 89.55% 89.56% +0.01%
==========================================
Files 425 425
Lines 20307 20309 +2
==========================================
+ Hits 18185 18189 +4
+ Misses 2122 2120 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@brandonjackson I have made a fix to properly overwrite the errors. This should fix all the errors in the other places |
Description
This PR fixes issue #4490 where sandbox name validation error messages were appearing twice on the create sandbox modal.
The root cause was in the
form_component.exwhereHelpers.copy_error/2was being called without theoverwrite: falseoption, causing validation errors to be duplicated when copied from the:namefield to the:raw_namefield.Changes:
lib/lightning_web/live/sandbox_live/form_component.exto passoverwrite: falsetoHelpers.copy_error/3, preventing duplicate error messagestest/lightning_web/live/sandbox_live/form_component_test.exsto verify that validation errors appear only onceCloses #4490
Validation steps
mix test test/lightning_web/live/sandbox_live/form_component_test.exsAdditional notes for the reviewer
The fix is minimal and surgical - it only changes the behavior of error copying to prevent overwriting existing errors. The test has been enhanced to explicitly verify the fix by counting occurrences of the error message.
AI Usage
Pre-submission checklist
/reviewwith Claude Code):owner,:admin,:editor,:viewer)https://claude.ai/code/session_01UJyPo9Uz83JMKQ2hCg97XC