{"record":{"id":"018e6564a5fd2ece","repo":"AlexxIT/go2rtc","slug":"hap-wrong-response-v-on-request-v","errorCode":null,"errorMessage":"hap: wrong response: %#v, on request: %#v","messagePattern":"hap: wrong response: %#v, on request: %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hap/helpers.go","lineNumber":129,"sourceCode":"\tfor _, item := range items {\n\t\tswitch v := item.(type) {\n\t\tcase string:\n\t\t\tb = append(b, v...)\n\t\tcase []byte:\n\t\t\tb = append(b, v[:]...)\n\t\tdefault:\n\t\t\tpanic(v)\n\t\t}\n\t}\n\treturn\n}\n\nfunc newRequestError(req any) error {\n\treturn fmt.Errorf(\"hap: wrong request: %#v\", req)\n}\n\nfunc newResponseError(req, res any) error {\n\treturn fmt.Errorf(\"hap: wrong response: %#v, on request: %#v\", res, req)\n}\n","sourceCodeStart":111,"sourceCodeEnd":131,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/hap/helpers.go#L111-L131","documentation":"newResponseError reports that a HAP control response did not match what was expected for the given request. Dial, Pair and DeletePairing use it when decoding a response whose structure or result fields are invalid. Both the response and the original request are dumped with %#v for diagnosis.","triggerScenarios":"Calling hap Dial/Pair/DeletePairing against an accessory whose reply body fails to decode into the expected response type, or whose TLV indicates an error/unsupported state.","commonSituations":"Targeting a non-HAP or wrong-version device (e.g. HAP 1.x quirks); the accessory rejected the pairing method and returned an error TLV; network proxy rewriting the response body.","solutions":["Inspect the dumped request/response to see which field the device returned instead of the expected one.","Confirm the accessory supports HAP pairing and is on the expected firmware/version.","Delete stale pairings on the accessory and re-pair from scratch.","Ensure the connection targets the accessory's HAP port (default 51826/TCP or advertised port), not another service."],"exampleFix":"// before\nconn, err := hap.Dial(accessoryAddr) // points at camera RTSP port 8554\n// after\nconn, err := hap.Dial(\"192.168.1.42:51826\") // actual HAP port","handlingStrategy":"retry","validationCode":"// verify host:port is the accessory HAP port before dialing\nconn, err := net.DialTimeout(\"tcp\", addr, 3*time.Second)","typeGuard":null,"tryCatchPattern":"conn, err := hap.Dial(addr)\nif err != nil {\n    if strings.Contains(err.Error(), \"wrong response\") {\n        // unpublish + re-pair\n    }\n    return err\n}","preventionTips":["Re-pair from scratch after firmware updates on the accessory","Confirm the device actually implements HAP on the dialed port","Avoid TLS-intercepting proxies between client and accessory","Pin the library version known to work with your accessory firmware"],"tags":["go","hap","homekit","protocol"],"backgroundTag":"unexpected-api-response-shape","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"}