From bfc58c8238655444d8aaddf74bbfb226801b1484 Mon Sep 17 00:00:00 2001 From: "blinkagent[bot]" <237617714+blinkagent[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2026 14:48:02 -0400 Subject: [PATCH] fix: show inline validation errors for URL-prefilled workspace names (#22347) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description When a workspace name is pre-filled via the `?name=` URL parameter (embed links), the Formik form did not mark the name field as "touched". This meant that Yup validation errors (e.g., name too long) were hidden from the user, and the form would submit to the server, which returned a generic "Validation failed" error banner instead of a clear inline message. ## Fix Include `name` in `initialTouched` when `defaultName` is provided from the URL, so validation errors display inline immediately — matching the behavior of manually typed names. ## Changes - `site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx`: Modified `initialTouched` to include `{ name: true }` when `defaultName` is set via URL parameter Fixes #22346 --------- Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com> Co-authored-by: Charlie Voiselle <464492+angrycub@users.noreply.github.com> --- .../CreateWorkspacePageView.stories.tsx | 12 ++++++++++++ .../CreateWorkspacePage/CreateWorkspacePageView.tsx | 3 +++ 2 files changed, 15 insertions(+) diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.stories.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.stories.tsx index 63acc69604..b7f53808f1 100644 --- a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.stories.tsx +++ b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.stories.tsx @@ -319,6 +319,18 @@ export const WithParameters: Story = { }, }; +export const WithTooLongPrefilledName: Story = { + args: { + defaultName: "this-name-is-way-too-long-and-exceeds-the-limit", + }, + play: async ({ canvasElement }) => { + const canvas = within(canvasElement); + await expect( + canvas.findByText(/Workspace Name cannot be longer than 32 characters/i), + ).resolves.toBeVisible(); + }, +}; + export const WithPresets: Story = { args: { presets: [ diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx index 7bc51ec138..0a544c52bc 100644 --- a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx +++ b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx @@ -127,6 +127,9 @@ export const CreateWorkspacePageView: FC = ({ const initialTouched = Object.fromEntries( parameters.filter((p) => autofillByName[p.name]).map((p) => [p.name, true]), ); + if (defaultName) { + initialTouched.name = true; + } // The form parameters values hold the working state of the parameters that will be submitted when creating a workspace // 1. The form parameter values are initialized from the websocket response when the form is mounted