{"record":{"id":"35b4463eae8e9a00","repo":"AlexxIT/go2rtc","slug":"not-homekit-source","errorCode":null,"errorMessage":"not homekit source","messagePattern":"not homekit source","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/homekit/api.go","lineNumber":159,"sourceCode":"\tconn, err := hap.Pair(url)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstreams.New(id, conn.URL())\n\n\treturn app.PatchConfig([]string{\"streams\", id}, conn.URL())\n}\n\nfunc apiUnpair(id string) error {\n\tstream := streams.Get(id)\n\tif stream == nil {\n\t\treturn errors.New(api.StreamNotFound)\n\t}\n\n\trawURL := findHomeKitURL(stream.Sources())\n\tif rawURL == \"\" {\n\t\treturn errors.New(\"not homekit source\")\n\t}\n\n\tif err := hap.Unpair(rawURL); err != nil {\n\t\treturn err\n\t}\n\n\tstreams.Delete(id)\n\n\treturn app.PatchConfig([]string{\"streams\", id}, nil)\n}\n\nfunc findHomeKitURLs() map[string]*url.URL {\n\turls := map[string]*url.URL{}\n\tfor name, sources := range streams.GetAllSources() {\n\t\tif rawURL := findHomeKitURL(sources); rawURL != \"\" {\n\t\t\tif u, err := url.Parse(rawURL); err == nil {\n\t\t\t\turls[name] = u\n\t\t\t}","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/homekit/api.go#L141-L177","documentation":"This error is returned by the HomeKit API unpair handler (apiUnpair) when a stream matching the requested stream name exists, but none of its source URLs is a HomeKit-compatible source. findHomeKitURL scans stream.Sources() for a URL scheme that the HAP (HomeKit Accessory Protocol) module can unpair from; when no source qualifies, the unpair operation cannot proceed.","triggerScenarios":"Calling the HomeKit unpair API endpoint for a stream whose sources are regular RTSP/HTTP/other URLs rather than a HomeKit (HAP) source; the stream name resolves via streams.Get but findHomeKitURL returns an empty string.","commonSituations":"Attempting to remove a HomeKit pairing for a camera that was never added as a HomeKit accessory, typos in the stream name resolving to the wrong stream, or a stream whose HomeKit source was removed/replaced with a non-HomeKit source in the config.","solutions":["Verify the stream's configured sources include a HomeKit-scheme URL that findHomeKitURL recognizes before calling unpair","Check the stream name in the unpair request matches the stream that actually has the HomeKit source","Re-add the HomeKit source to the stream config, unpair, then remove it","Skip unpairing for streams without HomeKit sources in client code"],"exampleFix":"// before\ncurl -X POST http://localhost:1984/api/homekit?stream=cam\n// after — only call unpair on streams whose source is a homekit URL\n// streams: cam: [\"homekit://...\", ...]  (ensure homekit source present)\ncurl -X POST http://localhost:1984/api/homekit?stream=cam","handlingStrategy":"validation","validationCode":"// Go: check stream sources for a homekit URL before calling unpair API\nurl := findHomeKitURL(stream.Sources())\nif url == \"\" {\n    return fmt.Errorf(\"stream %s has no homekit source; skip unpair\", name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only invoke the homekit unpair API for streams configured with homekit:// sources","Keep stream names and their source types documented","Validate stream config after changes to homekit sources"],"tags":["homekit","unpair","source-mismatch","api"],"backgroundTag":"incompatible-source-type","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}