grafana/k6 · error

error while parsing logfile configuration %w

Error message

error while parsing logfile configuration %w

What it means

Wraps a strvals.Parse failure inside parseArgs for the logfile config line. It fires when `file=...` arguments are not syntactically valid key=value tokens (e.g. unbalanced quotes or bad separators). The at-fault input is the malformed logfile configuration line; the underlying strvals error is wrapped with %w.

Source

Thrown at internal/log/file.go:64

	}

	logOutput, _, _ := strings.Cut(line, "=")
	if logOutput != "file" {
		return nil, fmt.Errorf("logfile configuration should be in the form `file=path-to-local-file` but is `%s`", line)
	}
	if err := hook.parseArgs(line); err != nil {
		return nil, err
	}
	if err := hook.openFile(getCwd); err != nil {
		return nil, err
	}
	return hook, nil
}

func (h *fileHook) parseArgs(line string) error {
	tokens, err := strvals.Parse(line)
	if err != nil {
		return fmt.Errorf("error while parsing logfile configuration %w", err)
	}

	for _, token := range tokens {
		switch token.Key {
		case "file":
			if token.Value == "" {
				return fmt.Errorf("filepath must not be empty")
			}
			h.path = token.Value
		case "level":
			h.levels, err = parseLevels(token.Value)
			if err != nil {
				return err
			}
		default:
			return fmt.Errorf("unknown logfile config key %s", token.Key)
		}
	}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Ensure the line is valid key=value pairs, e.g. file=/path/to/log and optionally level=debug
  2. Quote paths containing spaces or special characters correctly
  3. Inspect the wrapped strvals error for the exact syntax problem
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/log/file.go:64 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/dd432ee0e2611661. Report an issue: GitHub.