{"record":{"id":"5f217d961367fceb","repo":"siyuan-note/siyuan","slug":"path-must-not-be-empty","errorCode":null,"errorMessage":"--path must not be empty","messagePattern":"--path must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/asset.go","lineNumber":117,"sourceCode":"\t\t\tfmt.Fprintln(w, \"PATH\\tNAME\")\n\t\t\tfor _, item := range items {\n\t\t\t\tfmt.Fprintf(w, \"%s\\t%s\\n\", item.Item, item.Name)\n\t\t\t}\n\t\t\tw.Flush()\n\t\t\tfmt.Printf(\"\\n%d unused asset(s)\\n\", len(items))\n\t\t}\n\t\treturn nil\n\t},\n}\n\nvar assetCleanCmd = &cobra.Command{\n\tUse:   \"clean\",\n\tShort: \"Clean unused assets\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tsinglePath, _ := cmd.Flags().GetString(\"path\")\n\t\tif cmd.Flags().Changed(\"path\") {\n\t\t\tif singlePath == \"\" {\n\t\t\t\treturn fmt.Errorf(\"--path must not be empty\")\n\t\t\t}\n\t\t\tif dryRun {\n\t\t\t\trelativePath, _, err := model.ResolveUnusedDataAssetPath(singlePath)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tfmt.Printf(\"[dry-run] Would remove unused asset: %s\\n\", relativePath)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tret, err := model.RemoveUnusedAsset(singlePath)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfmt.Println(ret)\n\t\t\treturn nil\n\t\t}\n\n\t\tif dryRun {","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/asset.go#L99-L135","documentation":"The `asset clean` subcommand had its --path flag explicitly set (cmd.Flags().Changed(\"path\") is true) but the value is empty. Thrown at kernel/cli/cmd/asset.go:115-117. Without --path the command cleans all unused assets, so an explicit empty value is treated as a mistake rather than the bulk mode.","triggerScenarios":"Running `siyuan-kernel asset clean --path \"\"` or `--path=` or `--path \"$EMPTYVAR\"` where the variable expanded to empty.","commonSituations":"A shell variable for the path was unset or empty; the user passed --path intending bulk clean but the flag requires a concrete value when present.","solutions":["Drop the --path flag entirely to clean all unused assets: `asset clean`","Or supply a concrete unused-asset path: `asset clean --path assets/image/x.png`","If scripting, only add --path when the variable is non-empty"],"exampleFix":"# before (explicit empty)\nsiyuan-kernel asset clean --path \"\"\n\n# after (bulk clean — omit the flag entirely)\nsiyuan-kernel asset clean","handlingStrategy":"validation","validationCode":"// Only include --path when it has a value\nargs := []string{\"asset\",\"clean\"}\nif p != \"\" { args = append(args, \"--path\", p) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit --path entirely for bulk clean; only pass it with a concrete path","Guard shell variables so empty expansions never reach --path","Document that bare `asset clean` cleans all unused assets"],"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"}