larksuite/cli · error
file path cannot be empty after @
Error message
file path cannot be empty after @
What it means
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.
Source
Thrown at internal/cmdutil/resolve.go:57
return "", fmt.Errorf("failed to read stdin: %w", err)
}
s := strings.TrimSpace(string(data))
if s == "" {
return "", fmt.Errorf("stdin is empty (did you forget to pipe input?)")
}
return s, nil
}
// escape: @@... → literal @... (no file read)
if strings.HasPrefix(raw, "@@") {
return raw[1:], nil
}
// file: @path
if strings.HasPrefix(raw, "@") {
path := strings.TrimSpace(raw[1:])
if path == "" {
return "", fmt.Errorf("file path cannot be empty after @")
}
data, err := ReadInputFile(fileIO, path)
if err != nil {
return "", err
}
s := strings.TrimSpace(string(data))
if s == "" {
return "", fmt.Errorf("file %q is empty", path)
}
return s, nil
}
// strip surrounding single quotes (Windows cmd.exe passes them literally)
if len(raw) >= 2 && raw[0] == '\'' && raw[len(raw)-1] == '\'' {
raw = raw[1 : len(raw)-1]
}
return raw, nilView on GitHub (pinned to 7fd6ef3c07)
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
Example fix
// before FILE=""; lark-cli cmd --body "@$FILE" // after FILE=payload.json; lark-cli cmd --body "@$FILE"
Defensive patterns
Strategy: validation
Validate before calling
// shell
[ -n "$FILE" ] || { echo "FILE is empty"; exit 1; }
# Go caller:
if raw == "@" || strings.TrimSpace(strings.TrimPrefix(raw, "@")) == "" { /* reject before calling */ } Try / catch
if err != nil && strings.Contains(err.Error(), "file path cannot be empty after @") {
fmt.Fprintln(os.Stderr, "hint: --body requires a path after @, e.g. @payload.json")
} Prevention
- Quote "@${FILE}" so unset variables fail loudly (set -u)
- Validate the flag value before invoking the command
- Avoid building @-references from empty variables
When it happens
Trigger: Passing a value that is exactly "@" (or "@ " with only whitespace) to ParseOptionalBody/ParseJSONMap via --body or similar input flags.
Common situations: 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.
Related errors
- file %q is empty
- --header-scan-rows must be at least 1
- +csv-get truncated the requested range at {source_range}; na
- Pass exactly one of --url or --spreadsheet-token
- Pass only one of --sheet-id or --sheet-name
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/457b201433b1adcf.
Report an issue: GitHub.