Skip to content

fix(validation): disable deploy button for invalid agent names and sanitize namespaces#37

Merged
jwm4 merged 1 commit intosallyom:mainfrom
jwm4:fix/issue-7-agent-name-validation
Mar 22, 2026
Merged

fix(validation): disable deploy button for invalid agent names and sanitize namespaces#37
jwm4 merged 1 commit intosallyom:mainfrom
jwm4:fix/issue-7-agent-name-validation

Conversation

@jwm4
Copy link
Copy Markdown
Collaborator

@jwm4 jwm4 commented Mar 22, 2026

Summary

Fixes #7 — Deploy fails with agent names containing underscores.

Two gaps remained after partial validation was added:

  • Deploy button not disabled: The button at DeployForm.tsx:1662 used disabled={deploying} instead of disabled={deploying || !isValid}, so users could click Deploy when validation errors were shown (the handler returned early, but the UX was confusing)
  • No server-side namespace sanitization: namespaceName() in k8s-helpers.ts only called .toLowerCase() on agent names, passing through underscores and other RFC 1123-invalid characters to Kubernetes, which rejected them with a 422 error

Changes

  • src/client/components/DeployForm.tsx: Disable deploy button when form validation fails
  • src/server/deployers/k8s-helpers.ts: Add sanitizeForRfc1123() to replace invalid characters with hyphens; apply it in namespaceName() as defense in depth
  • src/client/components/__tests__/DeployForm.test.tsx: 3 regression tests for button disabled state and validation error display
  • src/server/deployers/__tests__/k8s-helpers.test.ts: 9 regression tests for sanitizeForRfc1123() and namespaceName() with invalid inputs

Test plan

  • All 105 tests pass (93 original + 12 new)
  • npm run build succeeds
  • npm run lint passes (0 errors)
  • Manual test: enter a_0 as agent name → button disabled, inline error shown
  • Manual test: enter my-agent → button enabled, no error

…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>
@jwm4 jwm4 force-pushed the fix/issue-7-agent-name-validation branch from f99e08b to 11bcb6b Compare March 22, 2026 13:23
@jwm4 jwm4 marked this pull request as ready for review March 22, 2026 13:23
@jwm4 jwm4 merged commit 506a781 into sallyom:main Mar 22, 2026
1 check passed
@jwm4 jwm4 deleted the fix/issue-7-agent-name-validation branch March 22, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deploy fails with agent names containing underscores -- no client-side validation

1 participant