Skip to content

WIP Add sandbox name validation with DNS label compliance - #76

Draft
dbmikus wants to merge 1 commit into
mainfrom
claude/sandbox-naming-restrictions-I0JR3
Draft

WIP Add sandbox name validation with DNS label compliance#76
dbmikus wants to merge 1 commit into
mainfrom
claude/sandbox-naming-restrictions-I0JR3

Conversation

@dbmikus

@dbmikus dbmikus commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds comprehensive validation for sandbox names to ensure they comply with DNS label requirements and maintain consistency across the system.

Key Changes

  • Added ValidateName() function in internal/sandbox/names.go that validates sandbox names against the following rules:

    • Must not be empty
    • Must be at most 63 characters (DNS label limit)
    • Must contain only lowercase letters, numbers, and hyphens
    • Cannot have leading, trailing, or consecutive hyphens
  • Added regex pattern validation using namePattern to enforce the allowed character set and hyphen placement rules

  • Added MaxNameLength constant set to 63 to match DNS label specifications

  • Integrated validation into CreateSandbox() in pkg/amika/service.go to validate user-provided sandbox names before creation

  • Added comprehensive test coverage in internal/sandbox/names_test.go:

    • TestValidateName() validates both valid and invalid name formats
    • TestGenerateNameIsValid() ensures auto-generated names always pass validation

Implementation Details

  • The validation uses a regex pattern ^[a-z0-9]+(-[a-z0-9]+)*$ to ensure hyphens only appear between alphanumeric segments
  • Validation is applied to user-provided names in the service layer, returning ErrInvalidArgument on failure
  • Auto-generated names (color-city format) are guaranteed to be valid by design

https://claude.ai/code/session_01TND4LDP6AZGUbi92edwe14

Restrict sandbox names to lowercase letters, numbers, and hyphens
(max 63 chars, no leading/trailing/consecutive hyphens). This ensures
names are valid DNS labels for domain name compatibility.

https://claude.ai/code/session_01TND4LDP6AZGUbi92edwe14
Base automatically changed from dylan/gh-cli-install-sandbox to main March 15, 2026 17:21
@dbmikus dbmikus changed the title Add sandbox name validation with DNS label compliance WIP Add sandbox name validation with DNS label compliance Mar 17, 2026
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.

2 participants