{"record":{"id":"dd432ee0e2611661","repo":"grafana/k6","slug":"error-while-parsing-logfile-configuration-w","errorCode":null,"errorMessage":"error while parsing logfile configuration %w","messagePattern":"error while parsing logfile configuration %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/log/file.go","lineNumber":64,"sourceCode":"\t}\n\n\tlogOutput, _, _ := strings.Cut(line, \"=\")\n\tif logOutput != \"file\" {\n\t\treturn nil, fmt.Errorf(\"logfile configuration should be in the form `file=path-to-local-file` but is `%s`\", line)\n\t}\n\tif err := hook.parseArgs(line); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := hook.openFile(getCwd); err != nil {\n\t\treturn nil, err\n\t}\n\treturn hook, nil\n}\n\nfunc (h *fileHook) parseArgs(line string) error {\n\ttokens, err := strvals.Parse(line)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error while parsing logfile configuration %w\", err)\n\t}\n\n\tfor _, token := range tokens {\n\t\tswitch token.Key {\n\t\tcase \"file\":\n\t\t\tif token.Value == \"\" {\n\t\t\t\treturn fmt.Errorf(\"filepath must not be empty\")\n\t\t\t}\n\t\t\th.path = token.Value\n\t\tcase \"level\":\n\t\t\th.levels, err = parseLevels(token.Value)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown logfile config key %s\", token.Key)\n\t\t}\n\t}","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/log/file.go#L46-L82","documentation":"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.","triggerScenarios":"Thrown at internal/log/file.go:64 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the line is valid key=value pairs, e.g. file=/path/to/log and optionally level=debug","Quote paths containing spaces or special characters correctly","Inspect the wrapped strvals error for the exact syntax problem"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}