siyuan-note/siyuan · error
--path is required
Error message
--path is required
What it means
The `asset stat` subcommand requires the --path flag (asset path relative to the data dir) but it was empty or omitted. Thrown by assetStatCmd.RunE at kernel/cli/cmd/asset.go:157-159. Unlike `asset clean`, here --path is mandatory in all cases.
Source
Thrown at kernel/cli/cmd/asset.go:159
if len(removed) == 0 {
fmt.Println("No unused assets to clean.")
return nil
}
for _, p := range removed {
fmt.Println(p)
}
fmt.Printf("\n%d asset(s) removed\n", len(removed))
return nil
},
}
var assetStatCmd = &cobra.Command{
Use: "stat --path <path>",
Short: "Show asset file info",
RunE: func(cmd *cobra.Command, args []string) error {
p, _ := cmd.Flags().GetString("path")
if p == "" {
return fmt.Errorf("--path is required")
}
relativePath, abs, err := model.ResolveDataAssetPath(p)
if err != nil {
return err
}
info, err := os.Stat(abs)
if err != nil {
return err
}
switch outputFormat {
case "json":
data, _ := json.MarshalIndent(map[string]any{
"path": relativePath,
"size": info.Size(),
"isDir": info.IsDir(),
"modTime": info.ModTime().Format("2006-01-02 15:04:05"),
}, "", " ")
fmt.Println(string(data))View on GitHub (pinned to 251596fc0d)
Solutions
- Pass a relative asset path: `asset stat --path assets/image/x.png`
- Confirm the path is relative to the workspace data dir, not absolute
- Use `asset stat --help` to see the expected path format
Example fix
# before siyuan-kernel asset stat # after siyuan-kernel asset stat --path assets/image/20260605100657-x.png
Defensive patterns
Strategy: validation
Validate before calling
if p == "" { return errors.New("--path is required") }
// Or: assetStatCmd.MarkFlagRequired("path") Prevention
- Mark --path required via cobra
- Pass paths relative to the workspace data dir, not absolute
- Use `asset stat --help` to confirm the expected path format
When it happens
Trigger: Running `siyuan-kernel asset stat` without --path, or with an empty --path value.
Common situations: The user forgot the path; a script variable for the path was empty; confusion with `asset clean` where --path is optional.
Related errors
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/45b37599421b7775.
Report an issue: GitHub.