{"record":{"id":"2a97eefbb5ae36cc","repo":"siyuan-note/siyuan","slug":"invalid-package-name-s","errorCode":null,"errorMessage":"invalid package name: %s","messagePattern":"invalid package name: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar_rating.go","lineNumber":84,"sourceCode":"\t\treturn nil, nil, errors.New(\"invalid package type\")\n\t}\n\n\tinstalledInfos, _, _, err := bazaarRatingInstalledPackageInfos(pkgType)\n\tif nil != err {\n\t\treturn nil, nil, err\n\t}\n\tinstalled := make(map[string]bool, len(installedInfos))\n\tfor _, info := range installedInfos {\n\t\tif \"\" == info.Pkg.InvalidReason {\n\t\t\tinstalled[info.Pkg.Name] = true\n\t\t}\n\t}\n\n\tnames := make([]string, 0, len(packageNames))\n\tseen := make(map[string]bool, len(packageNames))\n\tfor _, packageName := range packageNames {\n\t\tif !bazaar.IsValidPackageName(packageName) {\n\t\t\treturn nil, nil, fmt.Errorf(\"invalid package name: %s\", packageName)\n\t\t}\n\t\tif !installed[packageName] || seen[packageName] {\n\t\t\tcontinue\n\t\t}\n\t\tseen[packageName] = true\n\t\tnames = append(names, packageName)\n\t}\n\tif 0 == len(names) {\n\t\treturn map[string]*bazaar.PackageRating{}, []string{}, nil\n\t}\n\n\teligiblePackageNames, err = bazaarRatingExistingPackageNames(ctx, pkgType, names)\n\tif nil != err {\n\t\treturn nil, nil, err\n\t}\n\tif 0 == len(eligiblePackageNames) {\n\t\treturn map[string]*bazaar.PackageRating{}, eligiblePackageNames, nil\n\t}","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/bazaar_rating.go#L66-L102","documentation":"Error returned by model.GetInstalledBazaarPackageRatings (kernel/model/bazaar_rating.go:84) when any entry of packageNames fails bazaar.IsValidPackageName. That validator enforces a cross-platform-safe directory name: length 1..255, printable ASCII only (0x20..0x7E), no chars from `<>&'\":/\\|?*`, no leading/trailing dot or space, no \"..\" substring, and none of the Windows reserved device names (CON, PRN, AUX, NUL, COM1-9, LPT1-9, case-insensitive).","triggerScenarios":"Passing a package name containing CJK characters, spaces, slashes, quotes, or a reserved device name in packageNames to /api/bazaar/getInstalledBazaarPackageRatings; a client forwarding free-text search input as a package name list.","commonSituations":"Display names (e.g. \"Dark Theme (Pro)\") confused with package identifiers; names pasted with trailing whitespace; non-ASCII project names from non-English authors used where the ASCII identifier is required.","solutions":["Use the exact package identifier from the installed manifest (info.Pkg.Name), which was itself validated at install time","Filter each name through bazaar.IsValidPackageName before building the request","Strip whitespace and reject non-ASCII input at the UI layer"],"exampleFix":"// before\nratings, eligible, err := model.GetInstalledBazaarPackageRatings(ctx, pkgType, names) // names from free text\n\n// after\nfor _, n := range names {\n    if !bazaar.IsValidPackageName(n) {\n        return fmt.Errorf(\"skip invalid package name %q\", n)\n    }\n}\nratings, eligible, err := model.GetInstalledBazaarPackageRatings(ctx, pkgType, names)","handlingStrategy":"validation","validationCode":"filtered := names[:0]\nfor _, n := range names {\n    if bazaar.IsValidPackageName(n) {\n        filtered = append(filtered, n)\n    }\n}\nnames = filtered","typeGuard":"func isValidName(n string) bool { return bazaar.IsValidPackageName(n) }","tryCatchPattern":null,"preventionTips":["Only pass identifiers obtained from installed manifest data","Remember the rules: printable ASCII, no path/shell metacharacters, no Windows device names, no leading/trailing dot or space"],"tags":["marketplace","ratings","input-validation","package-name","ascii","reserved-names"],"backgroundTag":"input-validation-failed","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}