{"record":{"id":"c7cbbd545a17fdea","repo":"multica-ai/multica","slug":"render-shell-environment-policy-w","errorCode":null,"errorMessage":"render shell_environment_policy: %w","messagePattern":"render shell_environment_policy: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/daemon/execenv/codex_shell_env.go","lineNumber":119,"sourceCode":"\t\treturn strings.ToUpper(keys[i]) < strings.ToUpper(keys[j])\n\t})\n\treturn keys\n}\n\nfunc codexDefaultExcludesEnvKey(upperKey string) bool {\n\treturn strings.Contains(upperKey, \"KEY\") ||\n\t\tstrings.Contains(upperKey, \"SECRET\") ||\n\t\tstrings.Contains(upperKey, \"TOKEN\")\n}\n\nfunc renderMulticaShellEnvBlock(includeOnly []string) (string, error) {\n\tpolicy, err := toml.Marshal(codexShellEnvironmentPolicy{\n\t\tInherit:               \"all\",\n\t\tIgnoreDefaultExcludes: true,\n\t\tIncludeOnly:           includeOnly,\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"render shell_environment_policy: %w\", err)\n\t}\n\n\tvar b strings.Builder\n\tb.WriteString(multicaShellEnvBeginMarker)\n\tb.WriteByte('\\n')\n\tb.WriteString(\"[\")\n\tb.WriteString(shellEnvironmentPolicyKey)\n\tb.WriteString(\"]\\n\")\n\tb.Write(bytes.TrimRight(policy, \"\\n\"))\n\tb.WriteByte('\\n')\n\tb.WriteString(multicaShellEnvEndMarker)\n\tb.WriteByte('\\n')\n\treturn b.String(), nil\n}\n\n// stripUserShellEnvPolicy removes complete TOML expressions that define a\n// shell_environment_policy, including root dotted/inline values, quoted table\n// forms, nested set tables, and profile overlays. It deliberately preserves","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/execenv/codex_shell_env.go#L101-L137","documentation":"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.","triggerScenarios":"A code change adds a non-TOML-marshalable field (chan, func, NaN float) to codexShellEnvironmentPolicy; encoder version regression in the TOML library.","commonSituations":"Practically never seen at runtime; it exists so a marshal failure is reported with context instead of propagating raw.","solutions":["This is a developer-facing invariant: check recent changes to codexShellEnvironmentPolicy field types","Ensure include_only contains only strings"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"block, err := renderMulticaShellEnvBlock(includeOnly)\nif err != nil {\n\t// marshal of fixed struct fields: treat as a bug, fail loudly with the key list\n\tlog.Error(\"shell env render failed\", \"includeOnly\", includeOnly, \"err\", err)\n\treturn err\n}","preventionTips":["Keep codexShellEnvironmentPolicy fields string/[]string only","Add a unit test marshaling the struct so regressions surface in CI"],"tags":["toml","config","codex","invariant"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}