AlexxIT/go2rtc · error
streams: source empty
Error message
streams: source empty
What it means
GetOrPatch reads the `src` query parameter to locate or create a stream; when the parameter is absent or empty the request is meaningless, so the API handlers (WSHLS, MP4, WS, MSE, keyframe endpoints) return this error.
Solutions
- Add or fix the src query parameter in the request URL, e.g. /api/ws?src=camera1
- Verify the variable holding the stream name in the client/template isn't empty at request time
- When calling GetOrPatch directly, validate that query.Get("src") != "" before calling
Example fix
// before
const ws = new WebSocket(`ws://host/api/ws?src=${name}`); // name === ""
// after
if (!name) throw new Error("stream name required");
const ws = new WebSocket(`ws://host/api/ws?src=${encodeURIComponent(name)}`); Defensive patterns
Strategy: validation
Validate before calling
if query.Get("src") == "" {
return errors.New("src query parameter is required")
}
stream, err := streams.GetOrPatch(query) Try / catch
stream, err := streams.GetOrPatch(query)
if err != nil {
http.Error(w, "missing 'src' query parameter", http.StatusBadRequest)
return
} Prevention
- Always build stream consumer URLs with the src parameter
- Use URL templates in player code with required src validation
- Return HTTP 400 with a clear message in custom handlers when src is missing
When it happens
Trigger: Calling any stream consumer endpoint (e.g. /api/ws, /api/stream.mp4, /api/stream.m3u8) without `?src=...`, or with `src=` empty; programmatically calling streams.GetOrPatch(url.Values{}) with no src key.
Common situations: Embedded player code built with the stream name omitted; HTML templates that interpolate an empty src variable; frontend URL built after stream name fetch failed silently.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/921bae4891f7ae57.
Report an issue: GitHub.
Appendix: source
Thrown at internal/streams/streams.go:122
}
// check an existing stream with this name
if stream, ok := streams[name]; ok {
stream.SetSource(source)
return stream, nil
}
// create new stream with this name
stream := NewStream(source)
streams[name] = stream
return stream, nil
}
func GetOrPatch(query url.Values) (*Stream, error) {
// check if src param exists
source := query.Get("src")
if source == "" {
return nil, errors.New("streams: source empty")
}
// check if src is stream name
if stream := Get(source); stream != nil {
return stream, nil
}
// check if name param provided
if name := query.Get("name"); name != "" {
return Patch(name, source)
}
// return new stream with src as name
return Patch(source, source)
}
var log zerolog.Logger
View on GitHub (pinned to c245815e75)