{"record":{"id":"9c8c9162ebd489e3","repo":"AlexxIT/go2rtc","slug":"yaml-path-not-exist","errorCode":null,"errorMessage":"yaml: path not exist","messagePattern":"yaml: path not exist","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yaml/yaml.go","lineNumber":142,"sourceCode":"\n\tfor i := offset1; i < len(in); {\n\t\tindent, length := parseLine(in[i:])\n\t\tif indent+1 != length {\n\t\t\tif node.Column < indent+1 {\n\t\t\t\toffset1 = i + length\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\ti += length\n\t}\n\n\treturn\n}\n\nfunc addToEnd(in []byte, path []string, value any) ([]byte, error) {\n\tif len(path) != 2 || value == nil {\n\t\treturn nil, errors.New(\"yaml: path not exist\")\n\t}\n\n\tv := map[string]map[string]any{\n\t\tpath[0]: {path[1]: value},\n\t}\n\tpaste, err := Encode(v, 2)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn join(in, paste), nil\n}\n\nfunc join(items ...[]byte) []byte {\n\tn := len(items) - 1\n\tfor _, b := range items {\n\t\tn += len(b)\n\t}","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/yaml/yaml.go#L124-L160","documentation":"YAML patcher addToEnd guard: the requested path is not exactly two segments (len(path) != 2) or the value is nil. addToEnd can only append a new top.key -> sub.key -> value mapping; deeper or shallower paths cannot be synthesized at end-of-document and are rejected.","triggerScenarios":"Thrown at pkg/yaml/yaml.go:142 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restrict patch-add operations to two-level keys (top.sub)","Create intermediate structure in the YAML first, then patch the leaf","Handle nil values upstream instead of calling addToEnd with them"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}