{"record":{"id":"3eed7425e6424db5","repo":"amir20/dozzle","slug":"err-error-3eed74","errorCode":null,"errorMessage":"err.Error()","messagePattern":"err\\.Error\\(\\)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"internal/web/download.go","lineNumber":66,"sourceCode":"\tif r.URL.Query().Has(\"stdout\") {\n\t\tstdTypes |= container.STDOUT\n\t}\n\tif r.URL.Query().Has(\"stderr\") {\n\t\tstdTypes |= container.STDERR\n\t}\n\n\tif stdTypes == 0 {\n\t\thttp.Error(w, \"stdout or stderr is required\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// Parse filter regex if provided\n\tvar regex *regexp.Regexp\n\tvar err error\n\tif r.URL.Query().Has(\"filter\") {\n\t\tregex, err = support_web.ParseRegex(r.URL.Query().Get(\"filter\"))\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Inverse mode excludes lines matching the regex instead of keeping them.\n\tinverse := r.URL.Query().Get(\"inverse\") == \"true\"\n\n\t// Parse level filters if provided\n\tlevels := make(map[string]struct{})\n\tif r.URL.Query().Has(\"levels\") {\n\t\tfor _, level := range r.URL.Query()[\"levels\"] {\n\t\t\tlevels[level] = struct{}{}\n\t\t}\n\t}\n\n\t// Validate all containers before starting to write response\n\ttype containerInfo struct {\n\t\thostId           string","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/web/download.go#L48-L84","documentation":"downloadLogs returns a 400 with the regex parse error when the `filter` query parameter cannot be compiled as a regular expression. support_web.ParseRegex wraps regexp.Compile, so any syntactically invalid Go RE2 pattern (unbalanced parens, bad escape sequences, invalid character classes) is rejected before any container lookup happens.","triggerScenarios":"GET /api/hosts/{host}/containers/{id}/download with a query like ?filter=([a-] or ?filter=\\Q, i.e. any filter string that fails regexp.Compile.","commonSituations":"Users hand-crafting filter URLs; UI escaping bugs where user search input is placed raw into the query string; patterns copied from PCRE-flavored tools that use RE2-unsupported or invalid syntax.","solutions":["Validate the filter pattern with regexp.Compile before building the download URL.","URL-encode the filter parameter (encodeURIComponent / url.QueryEscape) so metacharacters survive transport.","Fall back to no filter if the pattern fails to compile."],"exampleFix":"// before\nconst url = `/api/hosts/${host}/containers/${id}/download?filter=${userInput}`\n// after\nconst re = new RegExp(userInput) // or regexp.Compile server-side\nif (!isValidGoRegex(userInput)) throw new Error('invalid filter regex')\nconst url = `/api/hosts/${host}/containers/${id}/download?filter=${encodeURIComponent(userInput)}`","handlingStrategy":"validation","validationCode":"function isValidGoRegex(p) {\n  try { new RegExp(p); return p.indexOf('\\\\') === -1 || !/\\\\[QEHAGKZR]/.test(p); } catch { return false; }\n}\nif (!isValidGoRegex(filter)) throw new Error(`invalid filter regex: ${filter}`)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["URL-encode the filter query parameter every time.","Stick to RE2-compatible syntax; avoid PCRE-only constructs.","Test filter patterns against regexp.Compile before shipping them in URLs."],"tags":["regex","http","validation"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}