hashicorp/nomad · error

error parsing HTTPMaxSize: %w

Error message

error parsing HTTPMaxSize: %w

What it means

ArtifactConfigFromAgent converts the agent's ArtifactConfig into the internal readonly ArtifactConfig. HTTPMaxSize is a human-readable byte size string (e.g. "100MB") parsed with humanize.ParseBytes; if the string is not a valid size expression, the parse error is wrapped with this message and construction aborts, returning nil config.

Source

Thrown at client/config/artifact.go:45

	DecompressionLimitSize      int64

	DisableArtifactInspection     bool
	DisableFilesystemIsolation    bool
	FilesystemIsolationExtraPaths []string
	SetEnvironmentVariables       string
}

// ArtifactConfigFromAgent creates a new internal readonly copy of the client
// agent's ArtifactConfig. The config should have already been validated.
func ArtifactConfigFromAgent(c *config.ArtifactConfig) (*ArtifactConfig, error) {
	httpReadTimeout, err := time.ParseDuration(*c.HTTPReadTimeout)
	if err != nil {
		return nil, fmt.Errorf("error parsing HTTPReadTimeout: %w", err)
	}

	httpMaxSize, err := humanize.ParseBytes(*c.HTTPMaxSize)
	if err != nil {
		return nil, fmt.Errorf("error parsing HTTPMaxSize: %w", err)
	}

	gcsTimeout, err := time.ParseDuration(*c.GCSTimeout)
	if err != nil {
		return nil, fmt.Errorf("error parsing GCSTimeout: %w", err)
	}

	gitTimeout, err := time.ParseDuration(*c.GitTimeout)
	if err != nil {
		return nil, fmt.Errorf("error parsing GitTimeout: %w", err)
	}

	hgTimeout, err := time.ParseDuration(*c.HgTimeout)
	if err != nil {
		return nil, fmt.Errorf("error parsing HgTimeout: %w", err)
	}

	s3Timeout, err := time.ParseDuration(*c.S3Timeout)

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Fix the HTTPMaxSize value in the agent config to a valid humanize byte string, e.g. "100MB", "1GB", "512MiB" (no space between number and unit)
  2. Pre-validate the value with humanize.ParseBytes before building the config to get a clearer failure point
  3. If the value comes from environment or templating, check the rendered agent config for empty/whitespace values
  4. Upgrade/verify the go-humanize version if using a unit you believe should be supported

Example fix

// before
client {
  artifact {
    http_max_size = "100 MB"
  }
}
// after
client {
  artifact {
    http_max_size = "100MB"
  }
}
Defensive patterns

Strategy: validation

Validate before calling

if _, err := humanize.ParseBytes(*c.HTTPMaxSize); err != nil {
    return fmt.Errorf("invalid http_max_size %q: %w", *c.HTTPMaxSize, err)
}

Type guard

func validByteSize(s *string) bool { if s == nil { return false }; _, err := humanize.ParseBytes(*s); return err == nil }

Try / catch

cfg, err := config.ArtifactConfigFromAgent(agentCfg)
if err != nil {
    if strings.Contains(err.Error(), "error parsing HTTPMaxSize") {
        return fmt.Errorf("fix http_max_size in agent config: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling ArtifactConfigFromAgent with an ArtifactConfig whose HTTPMaxSize pointer is set to a string humanize.ParseBytes cannot parse, such as "100 MB" (space), "100mB", "10GiB" without support, an empty string, or a bare number with a unit typo like "100mbz".

Common situations: Typo or unsupported unit in the client { artifact { http_max_size = ... } } HCL block of a Nomad agent config; config templating injecting an empty or malformed value; manually constructed configs in tests or API callers passing raw strings without validation.

Related errors


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