siyuan-note/siyuan · error

asset upload(s) failed

Error message

%d asset upload(s) failed

What it means

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.

Solutions

  1. Read the printed output (printAssetUploadCommandOutput) to see which files failed and why.
  2. Fix or remove the failing file paths and re-run the upload for those files.
  3. Check file permissions and that the workspace/kernel is reachable.
  4. Re-run the command; successful files may need exclusion to avoid duplicates.
Defensive patterns

Strategy: try-catch

Validate before calling

for f in "${FILES[@]}"; do [ -f "$f" ] || echo "warning: $f missing"; done

Try / catch

if ! siyuan asset upload --id "$ID" --file "$F"; then
    echo "upload failed, see per-file output above"
fi

Prevention

When it happens

Trigger: asset upload completed with failedFiles non-empty — one or more of the --file paths could not be uploaded (unreadable file, invalid path, kernel error).

Common situations: Files missing or renamed between list building and upload; permission errors; kernel rejecting a path; network/workspace issues during upload.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/99baafff36b06cc8. Report an issue: GitHub.

Appendix: 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 nil

View on GitHub (pinned to 9f775e8a12)