{"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":628,"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\t_, statErr := os.Lstat(installPath)\n\tif statErr != nil && !os.IsNotExist(statErr) {\n\t\treturn result, statErr\n\t}\n\tresult.Updated = statErr == nil\n\tif result.Updated && !overwrite {\n\t\treturn result, ErrLocalBazaarPackageExists","sourceCodeStart":610,"sourceCodeEnd":646,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/bazaar.go#L610-L646","documentation":"Thrown by InstallLocalBazaarPackage when installing an uploaded local archive whose package name collides with a built-in theme (daylight or midnight) or built-in icon (litheness). Built-in appearance assets are protected from overwrite because replacing them can break the default UI.","triggerScenarios":"Uploading and installing a local theme archive whose manifest name is 'daylight' or 'midnight', or a local icon archive whose name is 'litheness'. The check uses case-insensitive comparison (strings.EqualFold), so casing variants are also blocked.","commonSituations":"A user or packaging tool reused a built-in package name for a custom theme/icon, or tried to 'replace' the default appearance. The guard prevents corrupting the fallback theme/icon.","solutions":["Rename the package in its manifest (theme.json/icon.json) and archive to a non-built-in name before installing.","If you genuinely need a custom default, distribute it as a separate package rather than overwriting the built-in."],"exampleFix":"// theme.json\n// before\n{ \"name\": \"daylight\", ... }\n// after\n{ \"name\": \"my-daylight\", ... }","handlingStrategy":"validation","validationCode":"// Block built-in names before attempting local install.\nif (pkgType == \"themes\" && (strings.EqualFold(pkg.Name, \"daylight\") || strings.EqualFold(pkg.Name, \"midnight\"))) ||\n    (pkgType == \"icons\" && strings.EqualFold(pkg.Name, \"litheness\")) {\n    return fmt.Errorf(\"cannot overwrite built-in package %q\", pkg.Name)\n}","typeGuard":"func isBuiltInPkgName(pkgType, name string) bool {\n    switch pkgType {\n    case \"themes\":\n        return strings.EqualFold(name, \"daylight\") || strings.EqualFold(name, \"midnight\")\n    case \"icons\":\n        return strings.EqualFold(name, \"litheness\")\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Give custom themes/icons unique manifest names; never reuse built-in names.","Validate against the built-in name set before uploading a local archive.","Remember the comparison is case-insensitive (EqualFold)."],"tags":["bazaar","package-management","built-in","protection","local-install"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}