fix(validation): disable deploy button for invalid agent names and sanitize namespaces#37
Merged
jwm4 merged 1 commit intosallyom:mainfrom Mar 22, 2026
Merged
Conversation
…nitize namespaces The deploy button was not disabled when validation errors existed (only `deploying` was checked). Also, `namespaceName()` only called `.toLowerCase()` without replacing RFC 1123-invalid characters like underscores, which caused K8s 422 errors if invalid names reached the server. Fixes sallyom#7 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
f99e08b to
11bcb6b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #7 — Deploy fails with agent names containing underscores.
Two gaps remained after partial validation was added:
DeployForm.tsx:1662useddisabled={deploying}instead ofdisabled={deploying || !isValid}, so users could click Deploy when validation errors were shown (the handler returned early, but the UX was confusing)namespaceName()ink8s-helpers.tsonly called.toLowerCase()on agent names, passing through underscores and other RFC 1123-invalid characters to Kubernetes, which rejected them with a 422 errorChanges
src/client/components/DeployForm.tsx: Disable deploy button when form validation failssrc/server/deployers/k8s-helpers.ts: AddsanitizeForRfc1123()to replace invalid characters with hyphens; apply it innamespaceName()as defense in depthsrc/client/components/__tests__/DeployForm.test.tsx: 3 regression tests for button disabled state and validation error displaysrc/server/deployers/__tests__/k8s-helpers.test.ts: 9 regression tests forsanitizeForRfc1123()andnamespaceName()with invalid inputsTest plan
npm run buildsucceedsnpm run lintpasses (0 errors)a_0as agent name → button disabled, inline error shownmy-agent→ button enabled, no error