{"record":{"id":"86792efa83d3d114","repo":"AlexxIT/go2rtc","slug":"err-error-86792e","errorCode":null,"errorMessage":"err.Error()","messagePattern":"err\\.Error\\(\\)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/streams/api.go","lineNumber":38,"sourceCode":"\tif src == \"\" && r.Method != \"POST\" {\n\t\tapi.ResponseJSON(w, streams)\n\t\treturn\n\t}\n\n\t// Not sure about all this API. Should be rewrited...\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tstream := Get(src)\n\t\tif stream == nil {\n\t\t\thttp.Error(w, \"\", http.StatusNotFound)\n\t\t\treturn\n\t\t}\n\n\t\tcons := probe.Create(\"probe\", query)\n\t\tif len(cons.Medias) != 0 {\n\t\t\tcons.WithRequest(r)\n\t\t\tif err := stream.AddConsumer(cons); err != nil {\n\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tapi.ResponsePrettyJSON(w, stream)\n\n\t\t\tstream.RemoveConsumer(cons)\n\t\t} else {\n\t\t\tapi.ResponsePrettyJSON(w, streams[src])\n\t\t}\n\n\tcase \"PUT\":\n\t\tname := query.Get(\"name\")\n\t\tif name == \"\" {\n\t\t\tname = src\n\t\t}\n\n\t\tif _, err := New(name, query[\"src\"]...); err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/streams/api.go#L20-L56","documentation":"On GET /api/streams the handler builds a probe consumer and calls stream.AddConsumer(cons); an error here is returned verbatim with HTTP 500. AddConsumer fails when the stream cannot start or negotiate a media with the probe (no working producer, medias mismatch, or start failure).","triggerScenarios":"GET /api/streams?src=X&candidates=... where stream X exists but has no working source, or its producers cannot provide media compatible with the probe consumer's requested medias.","commonSituations":"Probe endpoint used to test a stream whose upstream RTSP camera is offline; AddConsumer's internal stream.Put/start fails on first consumer; medias= query excludes all available codecs.","solutions":["Verify the stream's producer (source URL) is reachable and working first","Read the returned error text — it identifies the failed producer/consumer negotiation","Retry without restrictive medias/candidates query parameters","Test the source URL directly (e.g. ffprobe) to confirm it streams"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check the stream has a live producer before probing\nconst info = await (await fetch(`/api/streams?src=${encodeURIComponent(src)}`)).json();\nif (!info || !info.producers || info.producers.length === 0) throw new Error('stream has no producer');","typeGuard":null,"tryCatchPattern":"const res = await fetch(`/api/streams?src=${src}&medias=...`);\nif (res.status === 500) { const msg = await res.text(); /* msg names AddConsumer failure; check source health */ }","preventionTips":["Confirm the underlying source (RTSP camera, file) is online before probing","Avoid over-restrictive medias/candidates query params","Use the probe endpoint as a health check with retry/backoff","Check go2rtc logs for producer start errors around the 500"],"tags":["http","streams","probe","consumer"],"backgroundTag":"http-error-response","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"}