{"record":{"id":"99baafff36b06cc8","repo":"siyuan-note/siyuan","slug":"d-asset-upload-s-failed","errorCode":null,"errorMessage":"%d asset upload(s) failed","messagePattern":"(.+?) asset upload\\(s\\) failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/asset.go","lineNumber":105,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfiles[i] = abs\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would upload %d file(s) to document %s\\n\", len(files), id)\n\t\t\treturn nil\n\t\t}\n\n\t\t_, succFiles, failedFiles, err := model.InsertLocalAssets(id, files, true)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tresult := newAssetUploadCommandOutput(succFiles, failedFiles)\n\t\tprintAssetUploadCommandOutput(result)\n\t\tif 0 < len(failedFiles) {\n\t\t\treturn fmt.Errorf(\"%d asset upload(s) failed\", len(failedFiles))\n\t\t}\n\t\treturn nil\n\t},\n}\n\nvar assetUnusedCmd = &cobra.Command{\n\tUse:   \"unused\",\n\tShort: \"List unused assets\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\titems := model.UnusedAssets(true)\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(items, \"\", \"  \")\n\t\t\tfmt.Println(string(data))\n\t\tdefault:\n\t\t\tif len(items) == 0 {\n\t\t\t\tfmt.Println(\"No unused assets found.\")\n\t\t\t\treturn nil","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/asset.go#L87-L123","documentation":"After running the asset upload, the command reports per-file successes/failures and then returns this aggregate error if any upload failed, so the CLI exits non-zero. It is the summary of individual file upload failures, not a single-cause error.","triggerScenarios":"asset upload completed with failedFiles non-empty — one or more of the --file paths could not be uploaded (unreadable file, invalid path, kernel error).","commonSituations":"Files missing or renamed between list building and upload; permission errors; kernel rejecting a path; network/workspace issues during upload.","solutions":["Read the printed output (printAssetUploadCommandOutput) to see which files failed and why.","Fix or remove the failing file paths and re-run the upload for those files.","Check file permissions and that the workspace/kernel is reachable.","Re-run the command; successful files may need exclusion to avoid duplicates."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for f in \"${FILES[@]}\"; do [ -f \"$f\" ] || echo \"warning: $f missing\"; done","typeGuard":null,"tryCatchPattern":"if ! siyuan asset upload --id \"$ID\" --file \"$F\"; then\n    echo \"upload failed, see per-file output above\"\nfi","preventionTips":["Pre-check that every path exists and is readable before upload.","Parse the printed output to identify failed files and retry only those.","Keep uploads idempotent so partial retries are safe."],"tags":["cli","upload","partial-failure"],"backgroundTag":"api-request-failed","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}