{"record":{"id":"bdf68faa78349431","repo":"thanos-io/thanos","slug":"failed-to-parser-config-version-s","errorCode":null,"errorMessage":"failed to parser config version: %s","messagePattern":"failed to parser config version: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/discovery/memcache/resolver.go","lineNumber":86,"sourceCode":"\n\t// First line should be \"CONFIG cluster 0 [length-of-payload-]\n\tconfigMetaComponents := strings.Split(configMeta, \" \")\n\tif len(configMetaComponents) != 4 {\n\t\treturn nil, fmt.Errorf(\"expected 4 components in config metadata, and received %d, meta: %s\", len(configMetaComponents), configMeta)\n\t}\n\n\tconfigSize, err := strconv.Atoi(configMetaComponents[3])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse config size from metadata: %s, error: %s\", configMeta, err)\n\t}\n\n\tconfigVersion, err := reader.ReadString('\\n')\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to find config version: %s\", err)\n\t}\n\tclusterConfig.version, err = strconv.Atoi(strings.TrimSpace(configVersion))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parser config version: %s\", err)\n\t}\n\n\tnodes, err := reader.ReadString('\\n')\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read nodes: %s\", err)\n\t}\n\n\tif len(configVersion)+len(nodes) != configSize {\n\t\treturn nil, fmt.Errorf(\"expected %d in config payload, but got %d instead\", configSize, len(configVersion)+len(nodes))\n\t}\n\n\tfor host := range strings.SplitSeq(strings.TrimSpace(nodes), \" \") {\n\t\tdnsIpPort := strings.Split(host, \"|\")\n\t\tif len(dnsIpPort) != 3 {\n\t\t\treturn nil, fmt.Errorf(\"node not in expected format: %s\", dnsIpPort)\n\t\t}\n\t\tport, err := strconv.Atoi(dnsIpPort[2])\n\t\tif err != nil {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/discovery/memcache/resolver.go#L68-L104","documentation":"The version line read from the CONFIG payload must be a decimal integer. parseConfig converts it with strconv.Atoi after trimming whitespace; on failure this error is returned (note the 'parser' typo in the message itself). It signals the payload stream is misaligned — the bytes expected to be the version line are not a number.","triggerScenarios":"The line following the metadata is non-numeric, e.g. because a wrong configSize token caused ReadString('\\n') to capture the wrong bytes, or the server emitted a status/error string instead of the version.","commonSituations":"Off-by-N framing errors shifting the parse position; custom servers writing the version with a prefix/suffix; corrupt or interleaved responses on a shared connection.","solutions":["Verify payload framing: the metadata size must exactly match the version+nodes line bytes.","Ensure the server writes the version as a bare decimal line (e.g. '1\\r\\n').","Check for connection multiplexing/proxying that could interleave other responses.","Fix test fixtures to include a numeric version line."],"exampleFix":"// before\n// payload: \"version-1\\nhost1|ip|port\\n\" -> Atoi(\"version-1\") fails\n// after\nfmt.Fprintf(w, \"CONFIG cluster 0 %d\\r\\n1\\r\\n%s\\r\\n\", len(payload), payload)","handlingStrategy":"validation","validationCode":"func validVersionLine(line string) error {\n    _, err := strconv.Atoi(strings.TrimSpace(line))\n    return err\n}","typeGuard":null,"tryCatchPattern":"cfg, err := discovery.parseConfig(reader)\nif err != nil && strings.Contains(err.Error(), \"config version\") {\n    return nil, fmt.Errorf(\"misaligned CONFIG payload from %s; check framing\", addr)\n}","preventionTips":["Write the version as a bare decimal line terminated by \\r\\n.","Verify the declared configSize matches actual bytes so parsing stays aligned.","Avoid multiplexing other responses over the same connection during CONFIG fetch.","Keep test fixtures spec-exact (numeric version line)."],"tags":["memcached","parsing","protocol","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}