{"record":{"id":"19468222fff7ca32","repo":"iOfficeAI/OfficeCLI","slug":"missing-argument-194682","errorCode":"missing_argument","errorMessage":"Either --file or --stdin must be specified","messagePattern":"Either --file or --stdin must be specified","errorType":"exception","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.Import.cs","lineNumber":83,"sourceCode":"                // StripBom for the same reason batch does it: File.ReadAllText\n                // (the --file branch below) drops a UTF-8 BOM implicitly, the\n                // stdin reader hands it through. Without this, `import --stdin`\n                // fed a BOM'd CSV put a stray U+FEFF inside the first header\n                // cell while `import --file` on the same bytes did not.\n                csvContent = StripBom(StdIn.ReadToEnd());\n            }\n            else if (source != null)\n            {\n                if (!source.Exists)\n                    throw new CliException($\"Source file not found: {source.FullName}\")\n                    {\n                        Code = \"file_not_found\"\n                    };\n                csvContent = File.ReadAllText(source.FullName, Encoding.UTF8);\n            }\n            else\n            {\n                throw new CliException(\"Either --file or --stdin must be specified\")\n                {\n                    Code = \"missing_argument\",\n                    Suggestion = \"Use --file <path> to specify a CSV/TSV file, or --stdin to read from standard input\"\n                };\n            }\n\n            // Determine delimiter: --format flag > file extension > default csv\n            char delimiter = ',';\n            if (!string.IsNullOrEmpty(format))\n            {\n                delimiter = format.ToLowerInvariant() switch\n                {\n                    \"tsv\" => '\\t',\n                    \"csv\" => ',',\n                    _ => throw new CliException($\"Unknown format: {format}. Use 'csv' or 'tsv'\")\n                    {\n                        Code = \"invalid_value\",\n                        ValidValues = [\"csv\", \"tsv\"]","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.Import.cs#L65-L101","documentation":"The import command needs CSV/TSV content from either a --file/--source path or --stdin. This fires when neither was supplied, so there is nothing to import.","triggerScenarios":"'officecli import out.xlsx' with no --file and no --stdin (e.g. in an interactive shell with no pipe).","commonSituations":"Forgetting the source flag in a script; assuming import reads a default file; a closed pipe with the flag also absent.","solutions":["Add --file <path> to read a CSV/TSV file.","Or pipe data and add --stdin: 'cat data.csv | officecli import out.xlsx --stdin'.","Ensure at least one of the two is always present in automation."],"exampleFix":"// before\nofficecli import out.xlsx\n// after\nofficecli import out.xlsx --file data.csv\n# or\ncat data.csv | officecli import out.xlsx --stdin","handlingStrategy":"validation","validationCode":"if (sourcePath is null && !Console.IsInputRedirected)\n    throw new ArgumentException(\n        \"Import needs --file <path> or piped --stdin.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In scripts, assert that either a source path arg or a redirected stdin is present before calling import.","Never rely on a default source file."],"tags":["import","missing-argument","stdin","csv"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}