{"record":{"id":"45b37599421b7775","repo":"siyuan-note/siyuan","slug":"path-is-required","errorCode":null,"errorMessage":"--path is required","messagePattern":"--path is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/asset.go","lineNumber":159,"sourceCode":"\t\tif len(removed) == 0 {\n\t\t\tfmt.Println(\"No unused assets to clean.\")\n\t\t\treturn nil\n\t\t}\n\t\tfor _, p := range removed {\n\t\t\tfmt.Println(p)\n\t\t}\n\t\tfmt.Printf(\"\\n%d asset(s) removed\\n\", len(removed))\n\t\treturn nil\n\t},\n}\n\nvar assetStatCmd = &cobra.Command{\n\tUse:   \"stat --path <path>\",\n\tShort: \"Show asset file info\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tp, _ := cmd.Flags().GetString(\"path\")\n\t\tif p == \"\" {\n\t\t\treturn fmt.Errorf(\"--path is required\")\n\t\t}\n\t\trelativePath, abs, err := model.ResolveDataAssetPath(p)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tinfo, err := os.Stat(abs)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(map[string]any{\n\t\t\t\t\"path\":    relativePath,\n\t\t\t\t\"size\":    info.Size(),\n\t\t\t\t\"isDir\":   info.IsDir(),\n\t\t\t\t\"modTime\": info.ModTime().Format(\"2006-01-02 15:04:05\"),\n\t\t\t}, \"\", \"  \")\n\t\t\tfmt.Println(string(data))","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/asset.go#L141-L177","documentation":"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.","triggerScenarios":"Running `siyuan-kernel asset stat` without --path, or with an empty --path value.","commonSituations":"The user forgot the path; a script variable for the path was empty; confusion with `asset clean` where --path is optional.","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"],"exampleFix":"# before\nsiyuan-kernel asset stat\n\n# after\nsiyuan-kernel asset stat --path assets/image/20260605100657-x.png","handlingStrategy":"validation","validationCode":"if p == \"\" { return errors.New(\"--path is required\") }\n// Or: assetStatCmd.MarkFlagRequired(\"path\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","asset","validation","cobra","flags"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}