{"record":{"id":"6441cad48faf7a4e","repo":"siyuan-note/siyuan","slug":"built-in-marketplace-package-cannot-be-overwritten","errorCode":null,"errorMessage":"built-in marketplace package cannot be overwritten","messagePattern":"built-in marketplace package cannot be overwritten","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar.go","lineNumber":637,"sourceCode":"// InstallLocalBazaarPackage 安装上传的本地集市包。\nfunc InstallLocalBazaarPackage(archivePath, frontend string, overwrite bool) (result *LocalBazaarPackageInstallResult, err error) {\n\tpkgType, pkg, sourcePath, cleanup, err := bazaar.ExtractLocalPackage(archivePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer cleanup()\n\n\tresult = &LocalBazaarPackageInstallResult{\n\t\tPackageType:   pkgType,\n\t\tPackageName:   pkg.Name,\n\t\tMinAppVersion: pkg.MinAppVersion,\n\t}\n\tinstallPath, _, err := getPackageInstallPath(pkgType, pkg.Name)\n\tif err != nil {\n\t\treturn result, err\n\t}\n\tif (pkgType == \"themes\" && isBuiltInTheme(pkg.Name)) || (pkgType == \"icons\" && isBuiltInIcon(pkg.Name)) {\n\t\treturn result, errors.New(\"built-in marketplace package cannot be overwritten\")\n\t}\n\tif bazaar.IsBelowRequiredAppVersion(pkg) {\n\t\treturn result, fmt.Errorf(\"%w: SiYuan %s or later is required\", ErrLocalBazaarPackageIncompatible, pkg.MinAppVersion)\n\t}\n\tif (pkgType == \"plugins\" && bazaar.IsIncompatiblePlugin(pkg, frontend)) ||\n\t\t(pkgType == \"themes\" && bazaar.IsIncompatibleTheme(pkg, frontend)) {\n\t\treturn result, ErrLocalBazaarPackageIncompatible\n\t}\n\n\tlocalBazaarInstallLock.Lock()\n\tdefer localBazaarInstallLock.Unlock()\n\tcontainsFile, statErr := bazaar.PackageDirContainsFile(installPath)\n\tif statErr != nil && !os.IsNotExist(statErr) {\n\t\treturn result, statErr\n\t}\n\tresult.Updated = containsFile\n\tif result.Updated && !overwrite {\n\t\treturn result, ErrLocalBazaarPackageExists","sourceCodeStart":619,"sourceCodeEnd":655,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/bazaar.go#L619-L655","documentation":"InstallLocalBazaarPackage rejects uploaded local packages that would overwrite SiYuan's built-in themes or icons. These ship with the app and must not be replaced by marketplace imports, so installation is refused before any files are touched.","triggerScenarios":"Importing a local .zip/.s2ip package whose package.json name equals a built-in theme (e.g. 'daylight', 'midnight') or built-in icon pack while pkgType is themes or icons.","commonSituations":"Repackaging a stock theme with modifications and trying to install it via the local-install dialog; a fork of a built-in theme kept the original name in package.json; automation scripts bulk-importing archives that collide with built-in names.","solutions":["Rename the package in its package.json (name field) to something unique and rebuild the archive","Install it only if you truly intend to replace stock assets — that path is blocked by design, so do not rename built-in files","Distribute it as a regular marketplace-style package with a distinct name"],"exampleFix":"// before: package.json of a modified built-in theme\n{ \"name\": \"daylight\", ... }\n// after\n{ \"name\": \"daylight-customized\", ... }","handlingStrategy":"validation","validationCode":"func isBuiltInName(pkgType, name string) bool {\n  if pkgType == \"themes\" { return model.IsBuiltInTheme(name) }\n  if pkgType == \"icons\" { return model.IsBuiltInIcon(name) }\n  return false\n}\n// call before InstallLocalBazaarPackage and reject early","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never ship a package.json reusing a built-in theme/icon name","Rename modified stock themes before repackaging","Validate package.json name against built-in lists in CI for package repos"],"tags":["marketplace","local-install","protected-resource","themes"],"backgroundTag":"operation-not-supported","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"}