{"record":{"id":"1a3f7ce2ba3fc7da","repo":"wavetermdev/waveterm","slug":"reading-input-file-w","errorCode":null,"errorMessage":"reading input file: %w","messagePattern":"reading input file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-debugterm.go","lineNumber":78,"sourceCode":"\t\tstdinData, err := io.ReadAll(WrappedStdin)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"reading stdin: %w\", err)\n\t\t}\n\t\ttermData, err := parseDebugTermStdinData(stdinData)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif mode == DebugTermModeDecode {\n\t\t\tWriteStdout(\"%s\", formatDebugTermDecode(termData))\n\t\t} else {\n\t\t\tWriteStdout(\"%s\", formatDebugTermHex(termData))\n\t\t}\n\t\treturn nil\n\t}\n\tif debugTermInput != \"\" {\n\t\tfileData, err := os.ReadFile(debugTermInput)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"reading input file: %w\", err)\n\t\t}\n\t\ttermData, err := parseDebugTermStdinData(fileData)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif mode == DebugTermModeDecode {\n\t\t\tWriteStdout(\"%s\", formatDebugTermDecode(termData))\n\t\t} else {\n\t\t\tWriteStdout(\"%s\", formatDebugTermHex(termData))\n\t\t}\n\t\treturn nil\n\t}\n\tif debugTermSize <= 0 {\n\t\treturn fmt.Errorf(\"size must be greater than 0\")\n\t}\n\tfullORef, err := resolveBlockArg()\n\tif err != nil {\n\t\treturn err","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-debugterm.go#L60-L96","documentation":"When --input is given, debugTermRun loads the capture file with os.ReadFile and wraps any failure (nonexistent path, permission denied, is-a-directory) as 'reading input file'. The file must contain raw debug term data.","triggerScenarios":"`wsh debugterm --input <path>` where the path does not exist, is misspelled, has no read permission, or is a directory.","commonSituations":"Typo in the capture file path; running from a different working directory with a relative path; file created by another user/with restrictive permissions; pointing at a directory instead of a file.","solutions":["Verify the path exists and is readable: ls -l <path>","Use an absolute path instead of a relative one","Check file permissions or run as a user with read access","Point --input at a file, not a directory"],"exampleFix":"// before\nwsh debugterm --input capture.bin        # file is in /tmp, cwd is home\n// after\nwsh debugterm --input /tmp/capture.bin","handlingStrategy":"validation","validationCode":"if [ ! -f \"$INPUT\" ] || [ ! -r \"$INPUT\" ]; then\n  echo \"input file missing or unreadable: $INPUT\" >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":"fileData, err := os.ReadFile(debugTermInput)\nif err != nil {\n\treturn fmt.Errorf(\"reading input file %q: %w\", debugTermInput, err)\n}","preventionTips":["Use absolute paths for --input","Check existence and readability (ls -l) before invoking","Ensure the file is a regular file, not a directory","Capture with output redirection to a known location first"],"tags":["file-io","cli","debug"],"backgroundTag":"file-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}