{"record":{"id":"9cd252c3af0d824b","repo":"direnv/direnv","slug":"invalid-arguments","errorCode":null,"errorMessage":"invalid arguments","messagePattern":"invalid arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/cmd_log.go","lineNumber":18,"sourceCode":"package cmd\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n)\n\n// CmdLog is `direnv log [--status | --error] <message>`\nvar CmdLog = &Cmd{\n\tName:   \"log\",\n\tDesc:   \"Logs a given message\",\n\tArgs:   []string{\"[--status | --error]\", \"<message>\"},\n\tAction: actionWithConfig(cmdLog),\n}\n\nfunc cmdLog(_ Env, args []string, c *Config) (err error) {\n\tif len(args) != 3 {\n\t\treturn errors.New(\"invalid arguments\")\n\t}\n\tlogType := args[1]\n\tmessage := args[2]\n\tswitch logType {\n\tcase \"--status\", \"-status\":\n\t\tlogStatus(c, message)\n\tcase \"--error\", \"-error\":\n\t\tlogError(c, message)\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid log-type '%s'\", logType)\n\t}\n\treturn nil\n}\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/direnv/direnv/blob/b00e451f547f39be7ab836d969054114a465a0f9/internal/cmd/cmd_log.go#L1-L32","documentation":"`direnv log` expects exactly the command name plus a log type (--status or --error) and a message, i.e. args must have length 3. cmdLog returns this error for any other argument count. The Args spec `[--status | --error] <message>` documents the expected shape.","triggerScenarios":"Calling `direnv log` with fewer than two operands (e.g. no message, or no status flag) or more than two, so `len(args) != 3`.","commonSituations":"Hook scripts or users log status messages and forget the `--status`/`--error` flag; messages containing unquoted spaces get word-split into multiple args making len(args) exceed 3.","solutions":["Invoke as `direnv log --status \"message\"` or `direnv log --error \"message\"`","Quote the message so it is passed as a single argument: `direnv log --status \"build done\"`","Verify the flag spelling is `--status` (or `-status`) as accepted by the switch"],"exampleFix":"// before\ndirenv log build done\n// after\ndirenv log --status \"build done\"","handlingStrategy":"validation","validationCode":"if [ \"$#\" -lt 2 ]; then echo \"usage: direnv log (--status|--error) <message>\" >&2; exit 2; fi\ndirenv log --status \"$*\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always quote log messages so they arrive as one argument","Include --status or --error explicitly; never rely on a default","Match arg count to the documented Args spec: exactly two operands"],"tags":["cli","argument-validation","direnv"],"backgroundTag":"missing-cli-argument","analyzedSha":"b00e451f547f39be7ab836d969054114a465a0f9","analyzedAt":"2026-09-05T21:39:49.983Z","contentChangedAt":"2026-09-05T21:39:49.983Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}