{"record":{"id":"457b201433b1adcf","repo":"larksuite/cli","slug":"file-path-cannot-be-empty-after","errorCode":null,"errorMessage":"file path cannot be empty after @","messagePattern":"file path cannot be empty after @","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmdutil/resolve.go","lineNumber":57,"sourceCode":"\t\t\treturn \"\", fmt.Errorf(\"failed to read stdin: %w\", err)\n\t\t}\n\t\ts := strings.TrimSpace(string(data))\n\t\tif s == \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"stdin is empty (did you forget to pipe input?)\")\n\t\t}\n\t\treturn s, nil\n\t}\n\n\t// escape: @@... → literal @... (no file read)\n\tif strings.HasPrefix(raw, \"@@\") {\n\t\treturn raw[1:], nil\n\t}\n\n\t// file: @path\n\tif strings.HasPrefix(raw, \"@\") {\n\t\tpath := strings.TrimSpace(raw[1:])\n\t\tif path == \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"file path cannot be empty after @\")\n\t\t}\n\t\tdata, err := ReadInputFile(fileIO, path)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\ts := strings.TrimSpace(string(data))\n\t\tif s == \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"file %q is empty\", path)\n\t\t}\n\t\treturn s, nil\n\t}\n\n\t// strip surrounding single quotes (Windows cmd.exe passes them literally)\n\tif len(raw) >= 2 && raw[0] == '\\'' && raw[len(raw)-1] == '\\'' {\n\t\traw = raw[1 : len(raw)-1]\n\t}\n\n\treturn raw, nil","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/cmdutil/resolve.go#L39-L75","documentation":"When input starts with @ (file reference), ResolveInput strips the @ and trims the remainder; if nothing remains there is no path to open. The library throws this to catch a malformed @ reference early instead of attempting an empty-path file open.","triggerScenarios":"Passing a value that is exactly \"@\" (or \"@ \" with only whitespace) to ParseOptionalBody/ParseJSONMap via --body or similar input flags.","commonSituations":"Shell quoting mistakes that drop the path (e.g. unexpanded empty variable: --body \"@$FILE\" with FILE unset); a truncated command line; copy-paste losing the filename.","solutions":["Supply the path after @, e.g. --body @payload.json","Check that the variable holding the filename is actually set and non-empty","Quote arguments so the shell does not strip the path"],"exampleFix":"// before\nFILE=\"\"; lark-cli cmd --body \"@$FILE\"\n// after\nFILE=payload.json; lark-cli cmd --body \"@$FILE\"","handlingStrategy":"validation","validationCode":"// shell\n[ -n \"$FILE\" ] || { echo \"FILE is empty\"; exit 1; }\n# Go caller:\nif raw == \"@\" || strings.TrimSpace(strings.TrimPrefix(raw, \"@\")) == \"\" { /* reject before calling */ }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"file path cannot be empty after @\") {\n    fmt.Fprintln(os.Stderr, \"hint: --body requires a path after @, e.g. @payload.json\")\n}","preventionTips":["Quote \"@${FILE}\" so unset variables fail loudly (set -u)","Validate the flag value before invoking the command","Avoid building @-references from empty variables"],"tags":["cli","file-input","argument-parsing"],"backgroundTag":"empty-file-path","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}