{"record":{"id":"0ab099f9e8364cae","repo":"hashicorp/nomad","slug":"invalid-name-s-0ab099","errorCode":null,"errorMessage":"invalid name '%s'","messagePattern":"invalid name '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/actions.go","lineNumber":89,"sourceCode":"\tif a == nil || o == nil {\n\t\treturn false\n\t}\n\treturn a.Name == o.Name &&\n\t\ta.Command == o.Command &&\n\t\tslices.Equal(a.Args, o.Args)\n}\n\nfunc (a *Action) Validate() error {\n\tif a == nil {\n\t\treturn nil\n\t}\n\n\tvar mErr *multierror.Error\n\tif a.Command == \"\" {\n\t\tmErr = multierror.Append(mErr, errors.New(\"command cannot be empty\"))\n\t}\n\tif !validJobActionName.MatchString(a.Name) {\n\t\tmErr = multierror.Append(mErr, fmt.Errorf(\"invalid name '%s'\", a.Name))\n\t}\n\n\treturn mErr.ErrorOrNil()\n}\n","sourceCodeStart":71,"sourceCodeEnd":94,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/actions.go#L71-L94","documentation":"Returned by JobAction.Validate in Nomad's structs package when a job action's Name does not match the validJobActionName regular expression. Job action names must follow Nomad's action naming convention (restricted character set/format); any name with disallowed characters, wrong casing, or invalid structure fails validation and is wrapped into the multierror returned to the API caller.","triggerScenarios":"Submitting a job (jobs/register or nomad job run) whose task-level actions block contains an action with a name failing validJobActionName, e.g. containing spaces, slashes, or empty-adjacent invalid characters.","commonSituations":"Hand-written HCL/JSON jobs with action names like \"my action\" or \"run/app\"; templating that injects un-validated names; upgrading Nomad to a version that introduced actions validation on previously lenient job specs.","solutions":["Rename the action to satisfy validJobActionName (lowercase alphanumeric segments joined by dashes/underscores, per the regexp).","Run 'nomad job validate' locally before submitting to catch invalid names early.","Update CI-generated job specs to sanitize/normalize action names.","Review the Nomad docs for job actions naming rules."],"exampleFix":"// before\nactions {\n  \"my action\" {\n    command = \"/bin/ls\"\n  }\n}\n// after\nactions {\n  \"my-action\" {\n    command = \"/bin/ls\"\n  }\n}","handlingStrategy":"validation","validationCode":"var validJobActionName = regexp.MustCompile(`^[a-zA-Z0-9_-]+$`)\nif !validJobActionName.MatchString(action.Name) {\n    return fmt.Errorf(\"action name %q is invalid; use alphanumerics, dashes or underscores\", action.Name)\n}","typeGuard":null,"tryCatchPattern":"if err := job.Validate(); err != nil {\n    if mErr, ok := err.(*multierror.Error); ok {\n        for _, e := range mErr.Errors {\n            if strings.Contains(e.Error(), \"invalid name\") {\n                // fix offending action name and resubmit\n            }\n        }\n    }\n    return err\n}","preventionTips":["Sanitize action names with a slugify function before generating job specs.","Run 'nomad job validate' in CI before submitting jobs.","Avoid spaces, slashes, and special characters in action names.","Keep action names lowercase alphanumerics joined by dashes."],"tags":["nomad","validation","job-spec","actions"],"backgroundTag":"schema-validation-failed","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"}