hashicorp/nomad · error

failed to parse max job source bytes: %w

Error message

failed to parse max job source bytes: %w

What it means

convertServerConfig parses server.job_max_source_size (a string like "1M") with hashicorp/go-humanize's ParseBytes to convert it to a byte count for the job source size limit. If the string is not a valid humanized byte size, the parse error is wrapped as "failed to parse max job source bytes" and config conversion fails.

Source

Thrown at command/agent/agent.go:706

						lsc.Verification.Interval, err)
				}
				conf.RaftLogStoreConfig.VerificationInterval = dur
			}
		}
	} else if bolt := agentConfig.Server.RaftBoltConfig; bolt != nil {
		// Backwards compatibility: migrate deprecated raft_boltdb settings
		conf.RaftLogStoreConfig.BoltDBNoFreelistSync = bolt.NoFreelistSync
		// Clear the legacy field after migration
		agentConfig.Server.RaftBoltConfig = nil
	}

	// Interpret job_max_source_size as bytes from string value
	if agentConfig.Server.JobMaxSourceSize == nil {
		agentConfig.Server.JobMaxSourceSize = new("1M")
	}
	jobMaxSourceBytes, err := humanize.ParseBytes(*agentConfig.Server.JobMaxSourceSize)
	if err != nil {
		return nil, fmt.Errorf("failed to parse max job source bytes: %w", err)
	}
	conf.JobMaxSourceSize = int(jobMaxSourceBytes)

	conf.Reporting = agentConfig.Reporting
	// Pass the server's production status through to the reporting config
	conf.Reporting.NonProduction = agentConfig.Server.NonProduction

	conf.KEKProviderConfigs = agentConfig.KEKProviders

	if startTimeout := agentConfig.Server.StartTimeout; startTimeout != "" {
		dur, err := time.ParseDuration(startTimeout)
		if err != nil {
			return nil, fmt.Errorf("failed to parse start_timeout: %v", err)
		} else if dur <= time.Duration(0) {
			return nil, fmt.Errorf("start_timeout should be greater than 0s")
		}
		conf.StartTimeout = dur
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set job_max_source_size to a valid humanized size, e.g. job_max_source_size = "10M" (units B, KB, MB, GB, TB supported).
  2. If a variable supplies the value, ensure it renders as a clean humanized string with no extra text.
  3. Omit the key entirely to use the default (1M).
  4. Run `nomad validate` on the config to catch the parse failure before restart.

Example fix

// before
server {
  job_max_source_size = "1x"
}
// after
server {
  job_max_source_size = "10M"
}
Defensive patterns

Strategy: validation

Validate before calling

if _, err := humanize.ParseBytes(sizeStr); err != nil {
    return fmt.Errorf("job_max_source_size %q is not a valid size (use e.g. 1M, 512KB, 2G): %v", sizeStr, err)
}

Prevention

When it happens

Trigger: Setting job_max_source_size to something humanize.ParseBytes cannot parse — e.g. "1GBi", "10 mb" with unexpected casing/spaces is tolerated but "1x", "abc", "" (empty string pointer), or a bare number with a bad suffix fails. Also triggered when templating injects a units-suffixed value like "1048576 bytes".

Common situations: Confusing SI vs binary suffixes or inventing suffixes ("1MBps"); environment-variable substitution leaving the value empty; setting it to a raw integer assuming it is bytes (that actually works with ParseBytes, but "1048576B" style mistakes are common); copy-paste from docs using a different size syntax.

Understand the failure class

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/364c9e578e1ed67a. Report an issue: GitHub.