siyuan-note/siyuan · error
%d asset upload(s) failed
Error message
%d asset upload(s) failed
What it means
After printing the per-file upload results, the `asset upload` command returns an aggregate error when any uploads failed, summarizing the count. The command is still a failure exit even though some files succeeded — check the printed per-file output for which paths failed and why.
Source
Thrown at kernel/cli/cmd/asset.go:105
if err != nil {
return err
}
files[i] = abs
}
if dryRun {
fmt.Printf("[dry-run] Would upload %d file(s) to document %s\n", len(files), id)
return nil
}
_, succFiles, failedFiles, err := model.InsertLocalAssets(id, files, true)
if err != nil {
return err
}
result := newAssetUploadCommandOutput(succFiles, failedFiles)
printAssetUploadCommandOutput(result)
if 0 < len(failedFiles) {
return fmt.Errorf("%d asset upload(s) failed", len(failedFiles))
}
return nil
},
}
var assetUnusedCmd = &cobra.Command{
Use: "unused",
Short: "List unused assets",
RunE: func(cmd *cobra.Command, args []string) error {
items := model.UnusedAssets(true)
switch outputFormat {
case "json":
data, _ := json.MarshalIndent(items, "", " ")
fmt.Println(string(data))
default:
if len(items) == 0 {
fmt.Println("No unused assets found.")
return nilView on GitHub (pinned to 8641553a1f)
Solutions
- Read the printed upload report (printAssetUploadCommandOutput) to identify the failed paths and their reasons
- Fix each failed file (missing path, permissions) or correct the target --id and re-run the upload for those files only
- Check kernel connectivity/auth if many files failed at once
- Make the script tolerant: treat the non-zero exit as 'partial success' and retry only the failed subset
Example fix
// before
siyuan asset upload --id $ID --file a.png --file b.png # exits 1: '1 asset upload(s) failed'
// after (retry only failures identified from the printed report)
siyuan asset upload --id $ID --file a.png --file b.png || {
siyuan asset upload --id $ID --file b.png
} Defensive patterns
Strategy: try-catch
Validate before calling
for f in "${files[@]}"; do
[ -r "$f" ] || echo "warning: $f is not readable and will fail upload"
done Try / catch
if err := assetUploadCmd.Execute(); err != nil {
if strings.Contains(err.Error(), "asset upload(s) failed") {
// parse printed report for failedFiles and retry them individually
os.Exit(1)
}
panic(err)
} Prevention
- Pre-verify every --file path exists and is readable before running the batch
- Upload in small batches so one bad file doesn't obscure others
- Keep the command output — it is the only record of which files failed
When it happens
Trigger: Running `asset upload` where at least one --file path failed — nonexistent source path, unreadable file, network/kernel API error during upload, or an invalid target id.
Common situations: Batch scripts uploading many files where one was locked/deleted mid-run; a typo in one path among many; kernel unreachable or auth expired partway through the batch; asset size or type rejected by the kernel.
Related errors
- --ids is required
- Account authentication failed, please login again
- Upload failed: %s
- Failed to insert asset file, please reopen the document
- --remote requires a URL
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/99baafff36b06cc8.
Report an issue: GitHub.