{"record":{"id":"3a7fe32ae1f7d946","repo":"amir20/dozzle","slug":"no-host-matching-q-found-call-list-hosts-to-see","errorCode":null,"errorMessage":"no host matching %q found; call list_hosts to see available hosts","messagePattern":"no host matching %q found; call list_hosts to see available hosts","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/tools_resolve.go","lineNumber":223,"sourceCode":"\t}\n\treturn false\n}\n\n// resolveHostRef resolves a host reference (id or name) to its host id.\nfunc resolveHostRef(hostRef string, deps ToolDeps) (string, error) {\n\thosts := deps.HostService.Hosts()\n\tvar byName []container.Host\n\tfor _, h := range hosts {\n\t\tif h.ID == hostRef {\n\t\t\treturn h.ID, nil\n\t\t}\n\t\tif strings.EqualFold(h.Name, hostRef) {\n\t\t\tbyName = append(byName, h)\n\t\t}\n\t}\n\tswitch len(byName) {\n\tcase 0:\n\t\treturn \"\", fmt.Errorf(\"no host matching %q found; call list_hosts to see available hosts\", hostRef)\n\tcase 1:\n\t\treturn byName[0].ID, nil\n\tdefault:\n\t\tnames := make([]string, len(byName))\n\t\tfor i, h := range byName {\n\t\t\tnames[i] = fmt.Sprintf(\"%s (id %s)\", h.Name, h.ID)\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"host name %q is ambiguous; matches: %s. Pass the host id instead\", hostRef, strings.Join(names, \"; \"))\n\t}\n}\n\n// ambiguousError builds an actionable error listing every candidate so the\n// caller can re-issue the call unambiguously. The hint is tailored to the\n// candidate set because the LLM reads it to choose its next action: when the\n// candidates span multiple hosts, host_id disambiguates; when they all sit on\n// one host, host_id is useless and only the exact id or full name will do.\nfunc ambiguousError(containerRef, hostRef string, candidates []container.Container, hostNames map[string]string) error {\n\tparts := make([]string, len(candidates))","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/cloud/tools_resolve.go#L205-L241","documentation":"resolveHostRef matches the hostRef string against host names (case-insensitive). Zero matches yields this error directing the caller to list_hosts. Multiple matches produce a different error listing the candidates.","triggerScenarios":"Calling a container tool with a host argument that matches no connected host name: typo, hostname that changed, or agent host currently disconnected so it is absent from the host list.","commonSituations":"Referring to hosts by DNS name when dozzle uses a different display name; Swarm node renamed; remote agent down so the host disappeared from HostService.","solutions":["Run list_hosts to see connected host names and ids","Use the exact host id instead of the name to avoid ambiguity","Reconnect the remote agent/fix connectivity if the expected host is missing"],"exampleFix":"// before\nfetchLogs({container_id: \"abc\", host: \"node-1.prod\"})\n// after\nconst hosts = await listHosts({})\nconst h = hosts.find(x => x.name === \"node-1\")  // exact listed name\nfetchLogs({container_id: \"abc\", host: h.id})","handlingStrategy":"validation","validationCode":"const hosts = await listHosts({}); if (hostRef && !hosts.some(h => h.id === hostRef || h.name.toLowerCase() === hostRef.toLowerCase())) throw new Error('host ' + hostRef + ' not connected');","typeGuard":"null","tryCatchPattern":"try { await fetchLogs({container_id: id, host: ref}) } catch (e) { if (/no host matching/.test(e.message)) { const hosts = await listHosts({}); console.warn('available hosts:', hosts.map(h => h.name)); } }","preventionTips":["Cache host ids from list_hosts instead of names","Re-list hosts after agent reconnects; names can disappear when hosts go offline","Prefer the host id form to sidestep name ambiguity"],"tags":["cloud-tools","host-resolution","resource-not-found"],"backgroundTag":"resource-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"}