siyuan-note/siyuan · error

invalid marketplace package manifest

Error message

invalid marketplace package manifest

What it means

After locating the manifest, ExtractLocalPackage parses it with ParsePackageJSON. If parsing fails or returns nil, the manifest exists but is not a valid marketplace package JSON (bad JSON syntax, missing required fields), so the whole extraction is aborted with this generic error and temp files are removed.

Solutions

  1. Validate the manifest as strict JSON (no comments, no trailing commas), e.g. with jq or a JSON linter
  2. Ensure required package fields (name, author, version, etc.) are present and non-empty
  3. Re-save the manifest as UTF-8 without BOM
  4. Compare against a known-good sample manifest of the same package type

Example fix

// before: { "name": "x", "version": "1.0", }  // trailing comma
// after: { "name": "x", "version": "1.0.0" }
Defensive patterns

Strategy: validation

Validate before calling

const raw = fs.readFileSync(path.join(pkgRoot, "plugin.json"), "utf8").replace(/^\uFEFF/, "");
const manifest = JSON.parse(raw);
if (!manifest.name || !manifest.version || !manifest.author) throw new Error("manifest missing required fields");

Try / catch

try { await installLocalPackage(zipPath); } catch (e) { if (String(e).includes("invalid marketplace package manifest")) { JSON.parse(fs.readFileSync("plugin.json", "utf8")); } }

Prevention

When it happens

Trigger: Calling ExtractLocalPackage with a package whose plugin.json/theme.json/icon.json/template.json/widget.json contains malformed JSON, is empty, or lacks required fields such as name/author/version.

Common situations: Hand-edited manifest with a trailing comma; file saved in wrong encoding (UTF-16/BOM); manifest fields removed when copying a template; JSONC comments left in the manifest.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at kernel/bazaar/local.go:83

		if info, statErr := os.Stat(candidate); statErr == nil && info.Mode().IsRegular() {
			if manifestPath != "" {
				err = errors.New("multiple marketplace package manifests found")
				cleanup()
				return
			}
			pkgType = packageType
			manifestPath = candidate
		}
	}
	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")
	}

View on GitHub (pinned to 9f775e8a12)