{"record":{"id":"b428cefee26734dc","repo":"amir20/dozzle","slug":"failed-to-parse-arguments-w-b428ce","errorCode":null,"errorMessage":"failed to parse arguments: %w","messagePattern":"failed to parse arguments: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/tools_containers.go","lineNumber":49,"sourceCode":"\t\t\tNCpu:          int32(h.NCPU),\n\t\t\tMemTotal:      h.MemTotal,\n\t\t\tDockerVersion: h.DockerVersion,\n\t\t\tAgentVersion:  h.AgentVersion,\n\t\t\tType:          h.Type,\n\t\t\tAvailable:     h.Available,\n\t\t}\n\t}\n\treturn &pb.CallToolResponse{\n\t\tSuccess: true,\n\t\tResult:  &pb.CallToolResponse_ListHosts{ListHosts: &pb.ListHostsResult{Hosts: result}},\n\t}, nil\n}\n\nfunc executeFindContainers(argsJSON string, deps ToolDeps) (*pb.CallToolResponse, error) {\n\tvar args findContainersArgs\n\tif argsJSON != \"\" {\n\t\tif err := json.Unmarshal([]byte(argsJSON), &args); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse arguments: %w\", err)\n\t\t}\n\t}\n\n\tcontainers, errs := deps.HostService.ListAllContainers(deps.Labels)\n\tlogHostErrors(errs)\n\thostNames := buildHostNameMap(deps.HostService)\n\n\tresult := make([]*pb.ContainerInfo, 0, len(containers))\n\tfor _, c := range containers {\n\t\tif args.Name != \"\" && !containsIgnoreCase(c.Name, args.Name) {\n\t\t\tcontinue\n\t\t}\n\t\tif args.Image != \"\" && !containsIgnoreCase(c.Image, args.Image) {\n\t\t\tcontinue\n\t\t}\n\t\tif args.State != \"\" && !strings.EqualFold(c.State, args.State) {\n\t\t\tcontinue\n\t\t}","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/cloud/tools_containers.go#L31-L67","documentation":"executeFindContainers optionally unmarshals its JSON arguments into findContainersArgs. Empty arguments are allowed (lists all containers), but if non-empty arguments are invalid JSON or contain wrong-typed fields, json.Unmarshal fails and the error is wrapped with this message.","triggerScenarios":"Calling the find_containers tool with a filter/name argument that is malformed JSON or of the wrong type (e.g. name as a number, or a JSON array instead of an object).","commonSituations":"Agent-generated payloads with unescaped characters; passing a JSON-escaped string instead of an object; template interpolation producing invalid JSON.","solutions":["Either omit arguments entirely (valid: lists all containers) or send a well-formed JSON object.","Check the wrapped json error for the offending field/type and correct it.","Log the exact argsJSON at the caller side to spot encoding problems before dispatch."],"exampleFix":"// before\nfind_containers(\"my-app\") // not a JSON object\n// after\nfind_containers({\"name\":\"my-app\"})","handlingStrategy":"validation","validationCode":"// omit args to list everything, or validate before sending\nconst argsJSON = filter ? JSON.stringify({ name: filter }) : \"\";","typeGuard":null,"tryCatchPattern":"try {\n  return await callTool(\"find_containers\", argsJSON);\n} catch (e) {\n  if (String(e).includes(\"failed to parse arguments\")) {\n    // fall back to calling with no arguments to list all containers\n    return await callTool(\"find_containers\", \"\");\n  }\n  throw e;\n}","preventionTips":["Remember find_containers tolerates empty arguments but not malformed ones.","Build filter payloads with JSON.stringify.","Validate the filter object shape against the tool schema."],"tags":["json","cloud-tools"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}