multica-ai/multica · error

validate generated config.toml shell environment policy

Error message

validate generated config.toml shell environment policy: %w

What it means

Fires when the newly rendered managed shell-env block, merged into the stripped config, fails TOML unmarshal validation. The generated file would be invalid, so it is never written and the original config is preserved unchanged.

Solutions

  1. Inspect the generated policy validation error and fix the shell environment configuration.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/internal/daemon/execenv/codex_shell_env.go:284 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/1836ac4a8e089237. Report an issue: GitHub.

Appendix: source

Thrown at server/internal/daemon/execenv/codex_shell_env.go:284

	withoutManaged := []byte(shellEnvBlockRe.ReplaceAllString(string(data), ""))
	stripped, err := stripUserShellEnvPolicy(withoutManaged)
	if err != nil {
		return err
	}
	block, err := renderMulticaShellEnvBlock(includeOnly)
	if err != nil {
		return err
	}

	base := strings.TrimRight(string(stripped), " \t\r\n")
	updated := block
	if base != "" {
		updated = base + "\n\n" + block
	}
	var validated map[string]any
	if err := toml.Unmarshal([]byte(updated), &validated); err != nil {
		return fmt.Errorf("validate generated config.toml shell environment policy: %w", err)
	}

	if updated == string(data) {
		return nil
	}
	if err := os.WriteFile(configPath, []byte(updated), 0o644); err != nil {
		return fmt.Errorf("write config.toml: %w", err)
	}
	if logger != nil {
		logger.Debug("codex shell environment: wrote managed shell_environment_policy",
			"config_path", configPath,
			"include_count", len(includeOnly),
		)
	}
	return nil
}

View on GitHub (pinned to 2c0912b6ec)