{"record":{"id":"07c0dfc5bb7bbaea","repo":"hashicorp/nomad","slug":"minimum-number-of-files-is-1-got-d","errorCode":null,"errorMessage":"minimum number of files is 1; got %d","messagePattern":"minimum number of files is 1; got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7895,"sourceCode":"\t}\n}\n\n// DefaultLogConfig returns the default LogConfig values.\nfunc DefaultLogConfig() *LogConfig {\n\treturn &LogConfig{\n\t\tMaxFiles:      10,\n\t\tMaxFileSizeMB: 10,\n\t\tDisabled:      false,\n\t}\n}\n\n// Validate returns an error if the log config specified are less than the\n// minimum allowed. Note that because we have a non-zero default MaxFiles and\n// MaxFileSizeMB, we can't validate that they're unset if Disabled=true\nfunc (l *LogConfig) Validate(disk *EphemeralDisk) error {\n\tvar mErr multierror.Error\n\tif l.MaxFiles < 1 {\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"minimum number of files is 1; got %d\", l.MaxFiles))\n\t}\n\tif l.MaxFileSizeMB < 1 {\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"minimum file size is 1MB; got %d\", l.MaxFileSizeMB))\n\t}\n\tif disk != nil {\n\t\tlogUsage := (l.MaxFiles * l.MaxFileSizeMB)\n\t\tif disk.SizeMB <= logUsage {\n\t\t\tmErr.Errors = append(mErr.Errors,\n\t\t\t\tfmt.Errorf(\"log storage (%d MB) must be less than requested disk capacity (%d MB)\",\n\t\t\t\t\tlogUsage, disk.SizeMB))\n\t\t}\n\t}\n\treturn mErr.ErrorOrNil()\n}\n\n// Task is a single process typically that is executed as part of a task group.\ntype Task struct {\n\t// Name of the task","sourceCodeStart":7877,"sourceCodeEnd":7913,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7877-L7913","documentation":"This error comes from LogConfig.Validate in nomad/structs/structs.go:7895. Nomad's LogConfig controls task stdout/stderr rotation; MaxFiles must be at least 1 because zero log files makes log collection meaningless. When a job's log block (or API-submitted LogConfig) specifies MaxFiles < 1, the job fails validation with this message.","triggerScenarios":"Submitting a job whose logs block sets max_files = 0 or a negative value; constructing LogConfig{MaxFiles: 0} programmatically and calling Validate(disk); API clients sending log.max_files < 1 in the job JSON/HCL.","commonSituations":"Users copy HCL templates and set max_files = 0 thinking it disables logging; tools generating job specs compute MaxFiles from an empty config value; misunderstanding that Disabled=true on the log block is the way to turn off logging, not max_files=0.","solutions":["Set max_files >= 1 in the job's logs block (default is 10).","To disable log collection entirely, use the task driver/logmon disabled mechanism or set logs disabled = true where supported, not max_files = 0.","If building LogConfig in Go, start from structs.DefaultLogConfig() and only override fields you need."],"exampleFix":"// before\nlogs {\n  max_files     = 0\n  max_file_size = 10\n}\n// after\nlogs {\n  max_files     = 10\n  max_file_size = 10\n}","handlingStrategy":"validation","validationCode":"if lc := job.Groups; lc != nil {\n  for _, tg := range job.TaskGroups {\n    for _, t := range tg.Tasks {\n      if t.LogConfig != nil && t.LogConfig.MaxFiles < 1 {\n        return fmt.Errorf(\"task %s: max_files must be >= 1, got %d\", t.Name, t.LogConfig.MaxFiles)\n      }\n    }\n  }\n}","typeGuard":"func validLogFiles(n *int) bool { return n != nil && *n >= 1 }","tryCatchPattern":null,"preventionTips":["Never set max_files = 0 to disable logging; use the disabled mechanism.","Start from DefaultLogConfig() when building configs in code.","Run nomad job validate in CI before submitting jobs."],"tags":["nomad","validation","job-spec","logging"],"backgroundTag":"invalid-config-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"}