amir20/dozzle · error
failed to parse arguments
Error message
failed to parse arguments: %w
What it means
parseStreamArgs unmarshals the raw JSON arguments of a stream_logs tool call; when json.Unmarshal fails the JSON is wrapped as 'failed to parse arguments'. The cloud tool caller sent a body that is not valid JSON or has wrong types for fetchLogsArgs fields.
Solutions
- Validate the tool-call arguments are well-formed JSON before sending
- Ensure all fetchLogsArgs fields have correct JSON types (strings for container_id, level, regex)
- Check for truncation of long arguments and re-send the complete payload
Example fix
// before
parseStreamArgs(`{container_id: web}`) // invalid JSON
// after
parseStreamArgs(`{"container_id": "web"}`) Defensive patterns
Strategy: validation
Validate before calling
if err := json.Valid([]byte(argsJSON)); err != nil { /* fix JSON before calling */ } Try / catch
resp, err := executeStreamLogs(ctx, deps, argsJSON, send)
if err != nil && strings.Contains(err.Error(), "failed to parse arguments") {
// log raw argsJSON and re-send sanitized JSON
} Prevention
- Serialize tool arguments with a JSON encoder, never string concatenation
- Validate JSON before sending tool calls
- Avoid single quotes and trailing commas in generated JSON
When it happens
Trigger: executeStreamLogs receives argsJSON that json.Unmarshal rejects: malformed JSON syntax, non-string values for string fields, or a non-object payload.
Common situations: LLM emitting truncated or single-quoted JSON in tool arguments; double-encoded JSON strings; missing quotes around keys; wrong types (regex given as object).
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/6e090a76a06b2142.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cloud/tools_stream.go:22
"context"
"encoding/json"
"fmt"
"regexp"
"strings"
"time"
"github.com/amir20/dozzle/internal/container"
pb "github.com/amir20/dozzle/proto/cloud"
"github.com/rs/zerolog/log"
)
// streamSender is a function that sends a ToolResponse to the cloud.
type streamSender func(resp *pb.ToolResponse) error
func parseStreamArgs(argsJSON string) (*fetchLogsArgs, *regexp.Regexp, error) {
var args fetchLogsArgs
if err := json.Unmarshal([]byte(argsJSON), &args); err != nil {
return nil, nil, fmt.Errorf("failed to parse arguments: %w", err)
}
if args.ContainerID == "" {
return nil, nil, fmt.Errorf("container_id is required")
}
var re *regexp.Regexp
if args.Regex != "" {
var err error
re, err = regexp.Compile(args.Regex)
if err != nil {
return nil, nil, fmt.Errorf("invalid regex pattern: %w", err)
}
}
return &args, re, nil
}
func matchesFilters(event *container.LogEvent, args *fetchLogsArgs, re *regexp.Regexp) (string, bool) {
if args.Level != "" && !strings.EqualFold(event.Level, args.Level) {View on GitHub (pinned to d9463cbe21)