multica-ai/multica · error
render shell_environment_policy: %w
Error message
render shell_environment_policy: %w
What it means
renderMulticaShellEnvBlock marshals the codexShellEnvironmentPolicy struct (inherit=all, ignore_default_excludes, include_only list) to TOML and the encoder returned an error. Encoding a plain string slice into these fixed string fields is essentially infallible in practice, so this error guards against encoder bugs or a future field type that cannot marshal.
Source
Thrown at server/internal/daemon/execenv/codex_shell_env.go:119
return strings.ToUpper(keys[i]) < strings.ToUpper(keys[j])
})
return keys
}
func codexDefaultExcludesEnvKey(upperKey string) bool {
return strings.Contains(upperKey, "KEY") ||
strings.Contains(upperKey, "SECRET") ||
strings.Contains(upperKey, "TOKEN")
}
func renderMulticaShellEnvBlock(includeOnly []string) (string, error) {
policy, err := toml.Marshal(codexShellEnvironmentPolicy{
Inherit: "all",
IgnoreDefaultExcludes: true,
IncludeOnly: includeOnly,
})
if err != nil {
return "", fmt.Errorf("render shell_environment_policy: %w", err)
}
var b strings.Builder
b.WriteString(multicaShellEnvBeginMarker)
b.WriteByte('\n')
b.WriteString("[")
b.WriteString(shellEnvironmentPolicyKey)
b.WriteString("]\n")
b.Write(bytes.TrimRight(policy, "\n"))
b.WriteByte('\n')
b.WriteString(multicaShellEnvEndMarker)
b.WriteByte('\n')
return b.String(), nil
}
// stripUserShellEnvPolicy removes complete TOML expressions that define a
// shell_environment_policy, including root dotted/inline values, quoted table
// forms, nested set tables, and profile overlays. It deliberately preservesView on GitHub (pinned to 2c0912b6ec)
Solutions
- This is a developer-facing invariant: check recent changes to codexShellEnvironmentPolicy field types
- Ensure include_only contains only strings
Defensive patterns
Strategy: try-catch
Try / catch
block, err := renderMulticaShellEnvBlock(includeOnly)
if err != nil {
// marshal of fixed struct fields: treat as a bug, fail loudly with the key list
log.Error("shell env render failed", "includeOnly", includeOnly, "err", err)
return err
} Prevention
- Keep codexShellEnvironmentPolicy fields string/[]string only
- Add a unit test marshaling the struct so regressions surface in CI
When it happens
Trigger: A code change adds a non-TOML-marshalable field (chan, func, NaN float) to codexShellEnvironmentPolicy; encoder version regression in the TOML library.
Common situations: Practically never seen at runtime; it exists so a marshal failure is reported with context instead of propagating raw.
Related errors
- parse config.toml before shell environment update: %w
- parse config.toml shell environment expressions: %w
- open %s %s: %w
- resolve %s %q: user home: %w
- %s %q uses unsupported ~user expansion
AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15).
Data as JSON: /api/errors/c7cbbd545a17fdea.
Report an issue: GitHub.