{"record":{"id":"3d9fa4891abc9d26","repo":"hashicorp/nomad","slug":"invalid-job-type-q","errorCode":null,"errorMessage":"Invalid job type: %q","messagePattern":"Invalid job type: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":4764,"sourceCode":"\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Job ID contains a space\"))\n\t} else if strings.Contains(j.ID, \"\\000\") {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Job ID contains a null character\"))\n\t}\n\tif j.Name == \"\" {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Missing job name\"))\n\t} else if strings.Contains(j.Name, \"\\000\") {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Job Name contains a null character\"))\n\t}\n\n\tif j.Namespace == \"\" {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Job must be in a namespace\"))\n\t}\n\tswitch j.Type {\n\tcase JobTypeCore, JobTypeService, JobTypeBatch, JobTypeSystem, JobTypeSysBatch:\n\tcase \"\":\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Missing job type\"))\n\tdefault:\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Invalid job type: %q\", j.Type))\n\t}\n\tif len(j.Datacenters) == 0 && !j.IsMultiregion() {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Missing job datacenters\"))\n\t} else {\n\t\tfor _, v := range j.Datacenters {\n\t\t\tif v == \"\" {\n\t\t\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Job datacenter must be non-empty string\"))\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(j.TaskGroups) == 0 {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Missing job task groups\"))\n\t}\n\tfor idx, constr := range j.Constraints {\n\t\tif err := constr.Validate(); err != nil {\n\t\t\touter := fmt.Errorf(\"Constraint %d validation failed: %s\", idx+1, err)\n\t\t\tmErr.Errors = append(mErr.Errors, outer)","sourceCodeStart":4746,"sourceCodeEnd":4782,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L4746-L4782","documentation":"Job.Validate() accepts only the known job types: core, service, batch, system, and sysbatch. An empty type yields 'Missing job type'; any other non-empty string fails with this error. The job type drives scheduler selection, so an unknown value cannot be dispatched.","triggerScenarios":"Submitting a job with type = \"daemon\", \"cron\", or any misspelled value (e.g. \"Ssystem\") via nomad job run or the jobs API.","commonSituations":"Confusing Nomad job types with other schedulers' terminology (e.g. 'daemon' or 'cron' — periodic jobs are service/batch with a cron trigger); case errors; hand-edited JSON specs.","solutions":["Set the job type to one of: service, batch, system, or sysbatch (core is reserved for internal use)","Use a periodic/cron trigger stanza on a batch or service job instead of inventing a 'cron' type","Validate with nomad job validate to catch typos before submission"],"exampleFix":"// before\njob \"app\" {\n  type = \"daemon\"\n}\n// after\njob \"app\" {\n  type = \"service\"\n}","handlingStrategy":"type-guard","validationCode":"switch j.Type {\ncase structs.JobTypeService, structs.JobTypeBatch, structs.JobTypeSystem, structs.JobTypeSysBatch:\n    // ok\ncase \"\":\n    return errors.New(\"missing job type\")\ndefault:\n    return fmt.Errorf(\"invalid job type %q\", j.Type)\n}","typeGuard":"func validJobType(t string) bool {\n    switch t {\n    case structs.JobTypeCore, structs.JobTypeService, structs.JobTypeBatch, structs.JobTypeSystem, structs.JobTypeSysBatch:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Always set type explicitly to service, batch, system, or sysbatch","Never use 'cron' or 'daemon' types; use periodic triggers on batch/service instead","Keep job type lowercase exactly as the constants define","Run nomad job validate in CI before submission"],"tags":["nomad","job","validation","jobspec"],"backgroundTag":"invalid-enum-value","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"}