Skip to content

Fix duplicate sandbox name validation error display#4519

Merged
midigofrank merged 4 commits intomainfrom
claude/fix-issue-4490-RM4e5
Mar 19, 2026
Merged

Fix duplicate sandbox name validation error display#4519
midigofrank merged 4 commits intomainfrom
claude/fix-issue-4490-RM4e5

Conversation

@brandonjackson
Copy link
Contributor

@brandonjackson brandonjackson commented Mar 10, 2026

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.ex where Helpers.copy_error/2 was being called without the overwrite: false option, causing validation errors to be duplicated when copied from the :name field to the :raw_name field.

Changes:

  • Modified lib/lightning_web/live/sandbox_live/form_component.ex to pass overwrite: false to Helpers.copy_error/3, preventing duplicate error messages
  • Updated the test in test/lightning_web/live/sandbox_live/form_component_test.exs to verify that validation errors appear only once
  • Added assertion to count error occurrences and ensure they only appear once

Closes #4490

Validation steps

  1. Navigate to the Sandboxes page
  2. Click "Create Sandbox"
  3. Leave the sandbox name blank and attempt to submit
  4. Verify that the "can't be blank" validation error appears only once in the modal
  5. Run the test suite: mix test test/lightning_web/live/sandbox_live/form_component_test.exs

Additional 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

  • I have used Claude Code
  • I have used another model
  • I have not used AI

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review with Claude Code)
  • I have implemented and tested all related authorization policies. (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

https://claude.ai/code/session_01UJyPo9Uz83JMKQ2hCg97XC

claude added 2 commits March 10, 2026 07:45
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
@github-project-automation github-project-automation bot moved this to New Issues in Core Mar 10, 2026
@brandonjackson brandonjackson requested a review from elias-ba March 10, 2026 07:47
@brandonjackson
Copy link
Contributor Author

Code Review: Fix sandbox name validation appearing twice (#4490)

Overview

One-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 :raw_name and :name fields independently failed validate_required, and then copy_error duplicated the :name error onto :raw_name.

Code Quality & Correctness

form_component.ex (line 321) — The fix is correct and minimal. Passing overwrite: false means copy_error only copies when :raw_name has no existing error, which is exactly the right behavior:

  • Blank name: :raw_name already has "can't be blank" → skip copy → 1 error
  • Duplicate name: :raw_name is clean, :name has "already exists" → copy → 1 error
  • Format error on :name: same as duplicate name case → works correctly

Test — The assertion counting occurrences of can't be blank in the HTML is a reasonable approach to catch regressions.

Potential Concern

There are 6 other copy_error(:name, :raw_name) calls across the codebase (project creation modal, collection modals, settings) that use the default overwrite: true. They likely have the same latent bug when :raw_name is blank. Consider applying the same fix to:

  • lib/lightning_web/live/collection_live/collection_creation_modal.ex:47
  • lib/lightning_web/live/dashboard_live/project_creation_modal.ex:30,63
  • lib/lightning_web/live/project_live/form_component.ex:97
  • lib/lightning_web/live/project_live/settings.ex:209
  • lib/lightning_web/live/project_live/collections_component.ex:100

This isn't blocking since the issue specifically reports the sandbox modal, but it's worth a follow-up.

Verdict

The fix is correct, focused, and well-tested. Ship it.

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.56%. Comparing base (5d4762c) to head (95ab087).
⚠️ Report is 5 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@theroinaochieng theroinaochieng marked this pull request as ready for review March 10, 2026 10:09
@theroinaochieng theroinaochieng self-requested a review March 10, 2026 10:09
@midigofrank midigofrank self-requested a review March 18, 2026 15:00
@midigofrank
Copy link
Collaborator

@brandonjackson I have made a fix to properly overwrite the errors. This should fix all the errors in the other places

@midigofrank midigofrank merged commit 5b2dd0e into main Mar 19, 2026
8 checks passed
@midigofrank midigofrank deleted the claude/fix-issue-4490-RM4e5 branch March 19, 2026 02:47
@github-project-automation github-project-automation bot moved this from New Issues to Done in Core Mar 19, 2026
midigofrank added a commit that referenced this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Sandbox name validation appears twice

4 participants