{"record":{"id":"b3236d2583f1c2d8","repo":"AlexxIT/go2rtc","slug":"api-streamnotfound-b3236d","errorCode":null,"errorMessage":"api.StreamNotFound","messagePattern":"api\\.StreamNotFound","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"internal/hass/api.go","lineNumber":50,"sourceCode":"\t\t// 3. dynamic link to Hass camera\n\t\tif _, err := streams.Patch(v.Name, v.Channels.First.Url); err == nil {\n\t\t\tapiOK(w, r)\n\t\t} else {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t}\n\n\t// /stream/{id}/channel/0/webrtc\n\tdefault:\n\t\ti := strings.IndexByte(r.RequestURI[8:], '/')\n\t\tif i <= 0 {\n\t\t\thttp.Error(w, \"\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\tname := r.RequestURI[8 : 8+i]\n\t\tstream := streams.Get(name)\n\t\tif stream == nil {\n\t\t\thttp.Error(w, api.StreamNotFound, http.StatusNotFound)\n\t\t\treturn\n\t\t}\n\n\t\tif err := r.ParseForm(); err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\ts := r.FormValue(\"data\")\n\t\toffer, err := base64.StdEncoding.DecodeString(s)\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\ts, err = webrtc.ExchangeSDP(stream, string(offer), \"hass/webrtc\", r.UserAgent())\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/hass/api.go#L32-L68","documentation":"Once the stream name is parsed, apiStream looks it up via streams.Get(name); if no stream with that name exists it returns api.StreamNotFound with HTTP 404. This means go2rtc has no registered stream under that identifier.","triggerScenarios":"GET/POST /stream/{name}/channel/0/webrtc where {name} was never added (no streams: entry in config, the /add call never ran, or the name is misspelled).","commonSituations":"Home Assistant integration referencing a camera whose stream was never registered; go2rtc restarted without persistent config so dynamic /add streams are gone; case-sensitive name mismatch; stream deleted while HA still references it.","solutions":["Add the stream first via POST /stream/{name}/add or define it under streams: in go2rtc.yaml","Verify the name matches exactly (case-sensitive) the stream name in go2rtc config","List existing streams (GET /api/streams) to confirm the expected name exists","If using dynamic add from HA, check the /add call succeeded before calling the webrtc endpoint"],"exampleFix":"// before\ncurl /api/stream/typo-name/channel/0/webrtc -> 404 stream not found\n// after\ncurl -X POST -d '{\"name\":\"cam1\",...}' /api/stream/cam1/add\ncurl /api/stream/cam1/channel/0/webrtc -> 200","handlingStrategy":"validation","validationCode":"const streams = await (await fetch('/api/streams')).json();\nif (!streams.some(s => s.name === streamName)) {\n  throw new Error(`stream \"${streamName}\" not registered in go2rtc`);\n}","typeGuard":null,"tryCatchPattern":"const res = await fetch(webrtcUrl, opts);\nif (res.status === 404) {\n  // api.StreamNotFound — register the stream via /add or go2rtc.yaml first\n}","preventionTips":["Register streams via /add or go2rtc.yaml before calling the webrtc endpoint","Remember stream names are case-sensitive","List streams (GET /api/streams) to verify names after restarts","Persist dynamic streams in config if go2rtc restarts frequently"],"tags":["http","not-found","stream","missing-resource"],"backgroundTag":"resource-not-found","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"}