{"record":{"id":"9ac53ee2405f6bce","repo":"t8y2/dbx","slug":"not-json-9ac53e","errorCode":null,"errorMessage":"not JSON","messagePattern":"not JSON","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agents/drivers/hive-go/discovery.go","lineNumber":249,"sourceCode":"\t\t\t}\n\t\t}\n\t\tif value, err := endpointFromPublishedHiveConfig(parameters); err == nil {\n\t\t\treturn value, nil\n\t\t}\n\t\tif strings.Contains(candidate, \"=\") {\n\t\t\tcontinue\n\t\t}\n\t\tif value, err := parseRegisteredEndpoint(candidate); err == nil {\n\t\t\treturn value, nil\n\t\t}\n\t}\n\treturn endpoint{}, fmt.Errorf(\"unsupported HiveServer2 ZooKeeper registration %q\", child)\n}\n\nfunc endpointFromRegistrationJSON(value string) (endpoint, error) {\n\tvar object map[string]any\n\tif json.Unmarshal([]byte(value), &object) != nil {\n\t\treturn endpoint{}, errors.New(\"not JSON\")\n\t}\n\tfor _, key := range []string{\"serverUri\", \"server_uri\", \"hiveServer2Uri\", \"uri\"} {\n\t\tif raw, ok := object[key].(string); ok && strings.TrimSpace(raw) != \"\" {\n\t\t\treturn parseRegisteredEndpoint(raw)\n\t\t}\n\t}\n\tif serviceRecordEndpoint, ok := endpointFromServiceRecord(object); ok {\n\t\treturn serviceRecordEndpoint, nil\n\t}\n\thost, _ := object[\"host\"].(string)\n\tif host == \"\" {\n\t\thost, _ = object[\"hostname\"].(string)\n\t}\n\tport := 0\n\tswitch value := object[\"port\"].(type) {\n\tcase float64:\n\t\tport = int(value)\n\tcase string:","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/hive-go/discovery.go#L231-L267","documentation":"endpointFromRegistrationJSON expects each HiveServer2 ZooKeeper registration payload to be a JSON object; if json.Unmarshal fails, the payload is not JSON and discovery discards the node with this error. Hive versions register either JSON service records or legacy host:port strings, so non-JSON payloads take the legacy path instead.","triggerScenarios":"parseHiveServerRegistration encountered a znode child whose data is neither valid JSON nor handled by the legacy parser — corrupted znode data, whitespace/garbage bytes, or a non-Hive node written into the discovery path.","commonSituations":"Foreign tools writing to /hiveserver2, Hive registered with a plain host:port string while the JSON parser was chosen, binary or truncated znode data after an ensemble crash, testing with handcrafted znode data.","solutions":["Inspect znode data with zkCli (get /hiveserver2/<node>) and remove garbage nodes","Ensure only HiveServer2 instances write to the discovery path","Point discovery at the correct znode; legacy host:port registrations should go through the legacy parser","Re-register/restart HiveServer2 to rewrite a clean registration record"],"exampleFix":"// before\nzk.Create(\"/hiveserver2/manual\", []byte(\"not json at all\"), ...)\n// after\nzk.Create(\"/hiveserver2/manual\", []byte(`{\"serverUri\":\"host:10000\"}`), ...)","handlingStrategy":"validation","validationCode":"func looksLikeJSON(data []byte) bool {\n    trimmed := bytes.TrimSpace(data)\n    return len(trimmed) > 0 && (trimmed[0] == '{' || trimmed[0] == '[')\n}\n// only route JSON-looking registrations to endpointFromRegistrationJSON","typeGuard":null,"tryCatchPattern":"endpoint, err := parseHiveServerRegistration(child, data)\nif err != nil && err.Error() == \"not JSON\" {\n    log.Printf(\"skipping non-JSON registration %q\", child)\n    return nil // skip node instead of failing discovery\n}","preventionTips":["Keep foreign writers out of the HiveServer2 discovery znode","Inspect suspicious znodes with zkCli before deleting them","Handle legacy host:port registrations separately from JSON records"],"tags":["zookeeper","json","parsing","hive"],"backgroundTag":"invalid-json-payload","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}