{"record":{"id":"8bb9808694e28df3","repo":"hashicorp/nomad","slug":"system-jobs-may-not-have-a-spread-block","errorCode":null,"errorMessage":"System jobs may not have a spread block","messagePattern":"System jobs may not have a spread block","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":4800,"sourceCode":"\t\t\tmErr.Errors = append(mErr.Errors, outer)\n\t\t}\n\t}\n\tif j.Type == JobTypeSystem {\n\t\tif j.Affinities != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"System jobs may not have an affinity block\"))\n\t\t}\n\t} else {\n\t\tfor idx, affinity := range j.Affinities {\n\t\t\tif err := affinity.Validate(); err != nil {\n\t\t\t\touter := fmt.Errorf(\"Affinity %d validation failed: %s\", idx+1, err)\n\t\t\t\tmErr.Errors = append(mErr.Errors, outer)\n\t\t\t}\n\t\t}\n\t}\n\n\tif j.Type == JobTypeSystem {\n\t\tif j.Spreads != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"System jobs may not have a spread block\"))\n\t\t}\n\t} else {\n\t\tfor idx, spread := range j.Spreads {\n\t\t\tif err := spread.Validate(); err != nil {\n\t\t\t\touter := fmt.Errorf(\"Spread %d validation failed: %s\", idx+1, err)\n\t\t\t\tmErr.Errors = append(mErr.Errors, outer)\n\t\t\t}\n\t\t}\n\t}\n\n\tconst MaxDescriptionCharacters = 1000\n\tif j.UI != nil {\n\t\tif len(j.UI.Description) > MaxDescriptionCharacters {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"UI description must be under 1000 characters, currently %d\", len(j.UI.Description)))\n\t\t}\n\t}\n\n\tif j.VersionTag != nil {","sourceCodeStart":4782,"sourceCodeEnd":4818,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L4782-L4818","documentation":"Job.Validate() rejects system jobs that declare spread blocks: 'System jobs may not have a spread block'. Spread distributes allocations across attributes of candidate nodes, which has no effect for system jobs that run on every eligible node.","triggerScenarios":"Registering or validating a job with type = \"system\" while j.Spreads is non-nil, i.e. a spread block exists in the job or group spec.","commonSituations":"Converting a service job to system type without deleting spread blocks, templating jobs that include spread by default, or an HCL refactor that left spread in place.","solutions":["Remove the spread block from the system job spec","If distribution is needed, restrict node eligibility with constraint blocks instead","Run 'nomad job validate' to confirm"],"exampleFix":"// before\njob \"sys\" {\n  type = \"system\"\n  group \"g\" {\n    spread {\n      attribute = \"${node.datacenter}\"\n    }\n  }\n}\n// after\njob \"sys\" {\n  type = \"system\"\n  group \"g\" {}\n}","handlingStrategy":"validation","validationCode":"if job.Type == \"system\" && len(job.Spreads) > 0 {\n    return errors.New(\"system jobs may not declare spread blocks\")\n}\nreturn nil","typeGuard":null,"tryCatchPattern":"if err := job.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"spread block\") {\n        return ErrSystemJobSpread\n    }\n    return err\n}","preventionTips":["Strip spread blocks when converting jobs to system type","Keep system-job templates minimal (no affinity/spread)","Add a spec linter that rejects spread under type=system"],"tags":["nomad","job-validation","system-job","spread"],"backgroundTag":"nomad-job-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"}