{"record":{"id":"650729e939d77107","repo":"multica-ai/multica","slug":"parse-config-toml-shell-environment-expressions","errorCode":null,"errorMessage":"parse config.toml shell environment expressions: %w","messagePattern":"parse config\\.toml shell environment expressions: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/daemon/execenv/codex_shell_env.go","lineNumber":181,"sourceCode":"\t\t\tif isCodexShellEnvPolicyPath(keys) {\n\t\t\t\tr, err := tomlTableHeaderLineRange(content, expr)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tranges = append(ranges, r)\n\t\t\t}\n\t\tcase unstable.KeyValue:\n\t\t\tfullKey := make([]string, 0, len(currentTable)+len(keys))\n\t\t\tfullKey = append(fullKey, currentTable...)\n\t\t\tfullKey = append(fullKey, keys...)\n\t\t\tif isCodexShellEnvPolicyPath(fullKey) {\n\t\t\t\tstart := int(expr.Raw.Offset)\n\t\t\t\tranges = append(ranges, tomlByteRange{start: start, end: start + int(expr.Raw.Length)})\n\t\t\t}\n\t\t}\n\t}\n\tif err := parser.Error(); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse config.toml shell environment expressions: %w\", err)\n\t}\n\treturn removeTOMLByteRanges(content, ranges)\n}\n\nfunc tomlNodeKeys(node *unstable.Node) []string {\n\tit := node.Key()\n\tkeys := make([]string, 0, 4)\n\tfor it.Next() {\n\t\tkeys = append(keys, string(it.Node().Data))\n\t}\n\treturn keys\n}\n\nfunc isCodexShellEnvPolicyPath(keys []string) bool {\n\tif len(keys) > 0 && keys[0] == shellEnvironmentPolicyKey {\n\t\treturn true\n\t}\n\treturn len(keys) >= 3 && keys[0] == \"profiles\" && keys[2] == shellEnvironmentPolicyKey","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/execenv/codex_shell_env.go#L163-L199","documentation":"After iterating expressions with the toml/unstable parser to locate shell_environment_policy byte ranges, parser.Error() reports a parse failure the iteration surfaced. The stable decode in step one passed, so this indicates an inconsistency the iterative parser rejects — e.g. constructs valid at decode time but malformed at expression level.","triggerScenarios":"Exotic-but-decodable TOML (mixed key styles, odd whitespace) that the unstable parser flags mid-iteration; a parser/library version mismatch in behavior.","commonSituations":"Machine-generated config.toml from third-party tools; TOML library upgrade changing parser strictness.","solutions":["Simplify the formatting of the user's config.toml (normalize quoting/key style) and retry","Delete the managed-range-containing sections and let the daemon rewrite them","Report the config sample if it decodes with toml.Unmarshal but fails here"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"stripped, err := stripUserShellEnvPolicy(content)\nif err != nil && strings.Contains(err.Error(), \"shell environment expressions\") {\n\t// stable decode passed but iterative parse failed: fall back to\n\t// regenerating the file from decoded values instead of byte surgery\n\tstripped, err = regenerateFromDecoded(content)\n}","preventionTips":["Normalize config.toml formatting (quoting, key style) before it enters task homes","Pin the TOML library version and test with real-world config samples"],"tags":["toml","config","parser","codex"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}