{"record":{"id":"a2fe45a80f1e7253","repo":"hashicorp/nomad","slug":"secret-name-must-match-regex-s","errorCode":null,"errorMessage":"secret name must match regex %s","messagePattern":"secret name must match regex (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":10635,"sourceCode":"\t\tPath:     s.Path,\n\t\tConfig:   confCopy.(map[string]any),\n\t\tEnv:      maps.Clone(s.Env),\n\t}\n}\n\nfunc (s *Secret) Validate() error {\n\tif s == nil {\n\t\treturn nil\n\t}\n\n\tvar mErr multierror.Error\n\n\tif s.Name == \"\" {\n\t\t_ = multierror.Append(&mErr, errors.New(\"secret name cannot be empty\"))\n\t}\n\n\tif !validSecretName.MatchString(s.Name) {\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"secret name must match regex %s\", validSecretName))\n\t}\n\n\tif s.Provider == \"\" {\n\t\t_ = multierror.Append(&mErr, errors.New(\"secret provider cannot be empty\"))\n\t}\n\n\tif s.Path == \"\" {\n\t\t_ = multierror.Append(&mErr, errors.New(\"secret path cannot be empty\"))\n\t}\n\n\tif s.Provider == \"nomad\" || s.Provider == \"vault\" {\n\t\tif len(s.Env) > 0 {\n\t\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"%s provider cannot use the env block\", s.Provider))\n\t\t}\n\t} else {\n\t\tif len(s.Config) > 0 {\n\t\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"custom plugin provider %s cannot use the config block\", s.Provider))\n\t\t}","sourceCodeStart":10617,"sourceCodeEnd":10653,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L10617-L10653","documentation":"Secret block validation error: the secret's name fails the validSecretName regex. Names are used in paths and env wiring, so they must stay within the allowed character set (the regex value is included in the message).","triggerScenarios":"Thrown at nomad/structs/structs.go:10635 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename the secret using only characters allowed by the regex shown in the message","Avoid spaces, slashes, and special characters in secret names"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}