{"record":{"id":"cf8876aa022b03e0","repo":"fatedier/frp","slug":"toml-line-d-column-d-s","errorCode":null,"errorMessage":"toml: line %d, column %d: %s","messagePattern":"toml: line (.+?), column (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/load.go","lineNumber":224,"sourceCode":"\n\t// Handle YAML content\n\tif strict {\n\t\t// In strict mode, always use our custom handler to support YAML merge\n\t\tif err := parseYAMLWithDotFieldsHandling(b, c); err != nil {\n\t\t\treturn enhanceDecodeError(err, originalBytes, !parsedFromTOML)\n\t\t}\n\t\treturn nil\n\t}\n\t// Non-strict mode, parse normally\n\treturn yaml.Unmarshal(b, c)\n}\n\n// formatTOMLError extracts line/column information from TOML decode errors.\nfunc formatTOMLError(err error) error {\n\tvar decErr *toml.DecodeError\n\tif errors.As(err, &decErr) {\n\t\trow, col := decErr.Position()\n\t\treturn fmt.Errorf(\"toml: line %d, column %d: %s\", row, col, decErr.Error())\n\t}\n\tvar strictErr *toml.StrictMissingError\n\tif errors.As(err, &strictErr) {\n\t\treturn strictErr\n\t}\n\treturn err\n}\n\n// enhanceDecodeError tries to add field path and line number information to JSON/YAML decode errors.\nfunc enhanceDecodeError(err error, originalContent []byte, includeLine bool) error {\n\tvar typeErr *json.UnmarshalTypeError\n\tif errors.As(err, &typeErr) && typeErr.Field != \"\" {\n\t\tif includeLine {\n\t\t\tline := findFieldLineInContent(originalContent, typeErr.Field)\n\t\t\tif line > 0 {\n\t\t\t\treturn fmt.Errorf(\"line %d: field \\\"%s\\\": cannot unmarshal %s into %s\", line, typeErr.Field, typeErr.Value, typeErr.Type)\n\t\t\t}\n\t\t}","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/fatedier/frp/blob/6c8a8d0a97d03b44e9528d30b30c70cb9d61b405/pkg/config/load.go#L206-L242","documentation":"When a TOML frp config file fails to decode, formatTOMLError converts the pelletier/go-toml DecodeError into a message with 1-indexed line and column of the offending syntax plus the parser's description. This gives precise locations for structural TOML errors (bad brackets, duplicate keys, invalid values).","triggerScenarios":"Loading a .toml frpc/frps config whose syntax is invalid: unclosed table [[proxies]], duplicate key in one table, wrong scalar syntax, stray characters. The TOML unmarshal path in LoadConfigureFromFile routes through this formatter.","commonSituations":"Hand-editing TOML configs and losing a bracket; snippets pasted from YAML docs into TOML files (colons/indentation); TOML files written by scripts with unescaped strings.","solutions":["Go to the reported line:column and fix the syntax pointed at","Run a TOML linter (taplo, toml-validate) over the file","If the file is actually YAML/JSON, rename it with the proper extension so frp picks the right parser"],"exampleFix":"# before (line 12 reported)\n[[proxies]\nname = \"web\"\n\n# after\n[[proxies]]\nname = \"web\"","handlingStrategy":"try-catch","validationCode":"// pre-validate TOML before loading\nif err := toml.Unmarshal(raw, map[string]any{}); err != nil { return fmt.Errorf(\"toml pre-check: %w\", err) }","typeGuard":null,"tryCatchPattern":"if err := config.LoadConfigureFromFile(path, &cfg, strict); err != nil { var decErr *toml.DecodeError; if errors.As(err, &decErr) { r, c := decErr.Position(); /* point editor at r:c */ } }","preventionTips":["Use a TOML-aware editor (taplo/inlay hints)","Run toml lint in CI","Keep YAML snippets out of .toml files"],"tags":["config","toml","parsing","syntax"],"backgroundTag":null,"analyzedSha":"6c8a8d0a97d03b44e9528d30b30c70cb9d61b405","analyzedAt":"2026-08-15T06:53:27.215Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}