{"record":{"id":"43143f265456dea1","repo":"amir20/dozzle","slug":"err-error-43143f","errorCode":null,"errorMessage":"err.Error()","messagePattern":"err\\.Error\\(\\)","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"internal/web/logs.go","lineNumber":114,"sourceCode":"\tif plainText {\n\t\tw.Header().Set(\"Content-Type\", \"text/plain; charset=UTF-8\")\n\t} else {\n\t\tw.Header().Set(\"Content-Type\", \"application/x-jsonl; charset=UTF-8\")\n\t}\n\n\tfrom, _ := time.Parse(time.RFC3339Nano, r.URL.Query().Get(\"from\"))\n\tto, _ := time.Parse(time.RFC3339Nano, r.URL.Query().Get(\"to\"))\n\tid := chi.URLParam(r, \"id\")\n\n\tstdTypes := parseStdTypes(r)\n\tif stdTypes == 0 {\n\t\thttp.Error(w, \"stdout or stderr is required\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tcontainerService, err := h.hostService.FindContainer(hostKey(r), id, h.resolveLabels(r))\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusNotFound)\n\t\treturn\n\t}\n\n\tdelta := max(to.Sub(from), time.Second*3)\n\n\tvar regex *regexp.Regexp\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\tinverse := r.URL.Query().Get(\"inverse\") == \"true\"\n\n\tonlyComplex := r.URL.Query().Has(\"jsonOnly\")\n\teverything := r.URL.Query().Has(\"everything\")","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/web/logs.go#L96-L132","documentation":"After stdtypes validation, fetchLogsBetweenDates resolves the container via FindContainer(hostKey(r), id). Failure returns a 404 with err.Error(): the host is unknown/unreachable or no container matches the id.","triggerScenarios":"GET the between-dates logs endpoint with a stale or wrong container id, or a host segment that does not match an available host.","commonSituations":"Querying historical logs for a container that was recreated (new id); host/agent offline; pods replaced in k8s producing new ids; URL shared from a different deployment.","solutions":["Look up the current container id from /api/containers.json before fetching logs.","Verify the host key corresponds to an existing, connected host.","For recreated containers, re-resolve by container name/label rather than a persisted id."],"exampleFix":"// before\nconst logs = await fetch(`/api/hosts/${h}~${persistedId}/logs?from=...&to=...&stdtypes=stdout`)\n// after\nconst c = await resolveCurrentContainer(persistedName)\nconst logs = await fetch(`/api/hosts/${c.host}~${c.id}/logs?from=...&to=...&stdtypes=stdout`)","handlingStrategy":"try-catch","validationCode":"const containers = await fetch('/api/containers.json').then(r => r.json());\nif (!containers.some(c => c.id === id && c.host === host)) throw new Error('container not found');","typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch(logsUrl);\n  if (res.status === 404) {\n    const fresh = await resolveContainerByName(name);\n    return fetchLogs(fresh.host, fresh.id);\n  }\n} catch (e) { /* handle */ }","preventionTips":["Re-resolve container ids after container recreation before fetching historical logs.","Confirm the host is connected before issuing historical log queries.","Cache container references by name/label rather than id."],"tags":["http","docker","resource-not-found"],"backgroundTag":"record-not-found","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"}