amir20/dozzle · error
failed to parse arguments
Error message
failed to parse arguments: %w
What it means
parseArgs is a generic helper that unmarshals a tool-call argsJSON string into a struct of type T. Any invalid JSON (syntax error or type mismatch against T) produces this wrapped error, which callers return as-is to the tool dispatcher.
Solutions
- Check the wrapped json error (errors.As for *json.UnmarshalTypeError or *json.SyntaxError) to pinpoint the bad field or offset.
- Ensure required tools receive a non-empty JSON object for argsJSON.
- Keep the Go args struct field types and json tags in sync with the schema published in AvailableTools().
Example fix
// before
args, err := parseArgs[fetchLogsArgs]("") // empty string -> parse error
// after
if argsJSON == "" { return nil, errors.New("missing required arguments") }
args, err := parseArgs[fetchLogsArgs](argsJSON) Defensive patterns
Strategy: validation
Validate before calling
function safeArgs(obj) {
if (obj === undefined || obj === null) throw new Error("parseArgs requires a non-empty args object");
return JSON.stringify(obj); // guarantees syntactically valid JSON
} Try / catch
args, err := parseArgs[fetchLogsArgs](argsJSON)
if err != nil {
var typeErr *json.UnmarshalTypeError
if errors.As(err, &typeErr) {
return nil, fmt.Errorf("field %s has wrong type", typeErr.Field)
}
return nil, err
} Prevention
- Never pass an empty string to parseArgs for tools with required arguments.
- Keep Go args struct json tags aligned with the published tool schema.
- Unit-test each tool's parseArgs path with valid and invalid payloads.
When it happens
Trigger: Any cloud tool using parseArgs receiving argsJSON that is not valid JSON for its target struct: empty string where args are required, trailing commas, wrong field types, or double-encoded JSON.
Common situations: Tool implementations forgetting that parseArgs (unlike executeFindContainers) does not tolerate empty args; agents emitting JSON strings instead of objects; struct field type changes making previously valid payloads invalid.
Understand the failure class
Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse arguments
- failed to parse arguments
- failed to parse arguments
- notifications are not configured on this host
- failed to parse arguments
AI-assisted analysis of amir20/dozzle@d9463cbe21 (2026-09-07).
Data as JSON: /api/errors/3ec6ab068259f368.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cloud/tools_helpers.go:18
package cloud
import (
"encoding/json"
"fmt"
"strings"
"time"
"github.com/amir20/dozzle/internal/container"
pb "github.com/amir20/dozzle/proto/cloud"
"github.com/rs/zerolog/log"
)
// parseArgs unmarshals argsJSON into a fresh value of T.
func parseArgs[T any](argsJSON string) (T, error) {
var args T
if err := json.Unmarshal([]byte(argsJSON), &args); err != nil {
return args, fmt.Errorf("failed to parse arguments: %w", err)
}
return args, nil
}
// buildHostNameMap creates a mapping from host ID to host name.
func buildHostNameMap(hostService ToolHostService) map[string]string {
hosts := hostService.Hosts()
m := make(map[string]string, len(hosts))
for _, h := range hosts {
m[h.ID] = h.Name
}
return m
}
// resolveHostName returns the host name for a given host ID, falling back to the ID itself.
func resolveHostName(hostID string, hostNames map[string]string) string {
if name, ok := hostNames[hostID]; ok {
return nameView on GitHub (pinned to d9463cbe21)