semaphoreui/semaphore · error
name can not be empty
Error message
name can not be empty
What it means
AccessKey.Validate rejects an AccessKey whose Name field is an empty string. Every access key stored in Semaphore (SSH key, login password, Ansible password vault, Git credentials) must have a non-empty name used as its identifier in the UI and API. The check runs before saving or serializing the key's secret.
Solutions
- Include a non-empty "name" field in the access-key request payload
- Trim whitespace from user-supplied names before sending; treat whitespace-only as empty and reject at the client
- If building the AccessKey struct in Go, set key.Name before calling Validate/SerializeSecret
Example fix
// before
key := AccessKey{Type: db.AccessKeyRoleGit, Secret: secret}
// after
key := AccessKey{Name: "deploy-key", Type: db.AccessKeyRoleGit, Secret: secret}
if err := key.Validate(false); err != nil {
log.Fatal(err)
} Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(key.Name) == "" {
return errors.New("access key name is required")
} Type guard
func hasName(key db.AccessKey) bool {
return strings.TrimSpace(key.Name) != ""
} Try / catch
if err := key.Validate(false); err != nil {
if strings.Contains(err.Error(), "name can not be empty") {
return fmt.Errorf("access key rejected: %w", err)
}
return err
} Prevention
- Always include the "name" field in access-key API payloads
- Trim and require names at the client/CI layer before submission
- Validate keys in Go with key.Validate(false) before UpdateAccessKey/SerializeSecret
When it happens
Trigger: Calling UpdateAccessKey with a request body lacking the "name" field, or SerializeSecret on an AccessKey object constructed with only a Secret/credentials payload and no Name.
Common situations: API clients POST/PUT /api/access-keys with only the key material but omit "name"; Terraform/Ansible automation building key JSON from variables where the name variable is unset; partial struct unmarshal after an API schema change.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- missing secret
- invalid environment secret type
- must be valid JSON
- key can not be empty
- values must be scalar
AI-assisted analysis of semaphoreui/semaphore@1774ccb71a (2026-09-07).
Data as JSON: /api/errors/bf67328eae71d28f.
Report an issue: GitHub.
Appendix: source
Thrown at db/AccessKey.go:153
type SshKey struct {
Login string `json:"login"`
Passphrase string `json:"passphrase"`
PrivateKey string `json:"private_key"`
}
type AccessKeyRole int
const (
AccessKeyRoleAnsibleUser = iota
AccessKeyRoleAnsibleBecomeUser
AccessKeyRoleAnsiblePasswordVault
AccessKeyRoleGit
)
func (key *AccessKey) Validate(validateSecretFields bool) error {
if key.Name == "" {
return fmt.Errorf("name can not be empty")
}
//if !validateSecretFields {
// return nil
//}
//switch key.Type {
//case AccessKeySSH:
// if key.SshKey.PrivateKey == "" {
// return fmt.Errorf("private key can not be empty")
// }
//case AccessKeyLoginPassword:
// if key.LoginPassword.Password == "" {
// return fmt.Errorf("password can not be empty")
// }
//}
return nilView on GitHub (pinned to 1774ccb71a)