siyuan-note/siyuan · error

invalid marketplace package archive

Error message

invalid marketplace package archive

What it means

extractLocalPackageArchive calls zip.OpenReader on the uploaded archive path. If the file cannot be opened as a ZIP (missing file, truncated download, not a zip at all), the specific OS/zip error is replaced with this generic error to avoid leaking internals.

Solutions

  1. Verify the file exists and is a real zip (unzip -t or file command)
  2. Re-download/re-export the package archive
  3. Ensure the package is built as a ZIP archive, not tar/gzip
  4. Check the path passed to InstallLocalBazaarPackage points to the archive, not a directory

Example fix

// before: path = "/downloads/my-plugin.tar.gz"
// after: rebuild as zip, path = "/downloads/my-plugin.zip"
Defensive patterns

Strategy: validation

Validate before calling

if (!fs.existsSync(zipPath) || !fs.statSync(zipPath).isFile()) throw new Error("archive missing");
if (fs.readFileSync(zipPath).subarray(0, 2).toString() !== "PK") throw new Error("not a ZIP archive");

Try / catch

try { await installLocalPackage(zipPath); } catch (e) { if (String(e).includes("invalid marketplace package archive")) { /* repack as zip and retry once */ } }

Prevention

When it happens

Trigger: Calling ExtractLocalPackage with a path to a nonexistent file, a .zip that is actually plain text or a tar.gz, or a partially downloaded/corrupted zip.

Common situations: User selects a .tar.gz instead of .zip; browser download interrupted; file renamed to .zip without converting; path points to a directory.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


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

Appendix: source

Thrown at kernel/bazaar/local.go:92

	}
	if manifestPath == "" {
		err = errors.New("marketplace package manifest not found")
		cleanup()
		return
	}

	pkg, err = ParsePackageJSON(manifestPath)
	if err != nil || pkg == nil {
		err = errors.New("invalid marketplace package manifest")
		cleanup()
	}
	return
}

func extractLocalPackageArchive(archivePath, destination string) error {
	reader, err := zip.OpenReader(archivePath)
	if err != nil {
		return errors.New("invalid marketplace package archive")
	}
	defer reader.Close()

	if len(reader.File) == 0 {
		return errors.New("marketplace package archive is empty")
	}
	if len(reader.File) > maxLocalPackageFileCount {
		return errors.New("marketplace package contains too many files")
	}

	var declaredTotal uint64
	for _, item := range reader.File {
		if item.UncompressedSize64 > maxLocalPackageFileSize {
			return errors.New("marketplace package contains a file that is too large")
		}
		if ^uint64(0)-declaredTotal < item.UncompressedSize64 {
			return errors.New("marketplace package is too large")
		}

View on GitHub (pinned to 9f775e8a12)