crowdsecurity/crowdsec · error

unable to write overrides to '%s': %w

Error message

unable to write overrides to '%s': %w

What it means

After successfully marshaling the override statics, InstallHub writes them to <RuntimePath>/parsers/s00-raw/00_overrides.yaml. If os.WriteFile fails, the error is wrapped as 'unable to write overrides to <path>: %w' so the destination path is included. This indicates a filesystem-level problem in the test runtime directory.

Source

Thrown at pkg/hubtest/hubtest_item.go:226

	if err := t.installHubItems(t.Config.AppsecRules, t.installAppsecRule); err != nil {
		return err
	}

	if len(t.Config.OverrideStatics) > 0 {
		cfg := parser.NodeConfig{
			Name:    "overrides",
			Filter:  "1==1",
			Statics: t.Config.OverrideStatics,
		}

		b, err := yaml.Marshal(cfg)
		if err != nil {
			return fmt.Errorf("unable to serialize overrides: %w", err)
		}

		tgtFilename := fmt.Sprintf("%s/parsers/s00-raw/00_overrides.yaml", t.RuntimePath)
		if err := os.WriteFile(tgtFilename, b, os.ModePerm); err != nil {
			return fmt.Errorf("unable to write overrides to '%s': %w", tgtFilename, err)
		}
	}

	// load installed hub
	hub, err := cwhub.NewHub(t.RuntimeHubConfig, nil)
	if err != nil {
		return err
	}

	if err := hub.Load(); err != nil {
		return err
	}

	// prevent concurrent downloads of the same file
	downloadMutex.Lock()
	defer downloadMutex.Unlock()

	// install data for parsers if needed

View on GitHub (pinned to 909b515798)

Solutions

  1. Check the wrapped error: EACCES -> fix permissions (chmod/chown the runtime dir); ENOENT -> ensure the runtime environment was initialized; ENOSPC -> free disk space.
  2. Recreate the runtime environment directory (`mkdir -p <RuntimePath>/parsers/s00-raw`) and ensure the process user can write to it.
  3. Re-run test setup (e.g. the code path that creates the runtime environment) before calling Run.

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

target := filepath.Join(runtimePath, "parsers", "s00-raw")
if err := os.MkdirAll(target, 0o755); err != nil {
    return err
}
if f, err := os.CreateTemp(target, ".probe"); err != nil {
    return fmt.Errorf("runtime dir not writable: %w", err)
} else { f.Close(); os.Remove(f.Name()) }

Try / catch

err := item.Run(ctx)
if err != nil && strings.Contains(err.Error(), "unable to write overrides") {
    os.MkdirAll(filepath.Join(item.RuntimePath, "parsers", "s00-raw"), 0o755)
    // retry or report FS problem (permissions/disk full)
}

Prevention

When it happens

Trigger: HubTestItem.Run -> InstallHub with a runtime directory that does not exist, is read-only, or lacks write permissions — os.WriteFile cannot create/replace 00_overrides.yaml.

Common situations: RuntimePath on a read-only volume or tmpfs that filled up; the runtime environment was cleaned (parsers/s00-raw removed) before the override step; running under a different user (Docker root vs host user) without write permission; disk quota exceeded.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/ff728a8bc38523b4. Report an issue: GitHub.