Repository navigation
Add marketplace v2 contracts and parsing - #2880
Conversation
| iconTinted: z.boolean().default(false), | ||
| category: z.string(), | ||
| categoryId: pluginCatalogCategoryIdSchema.optional(), | ||
| category: z.string().optional(), |
There was a problem hiding this comment.
🚨 slopcop/review — An optional category breaks older SDK clients
High: The old SDK requires category. The new server omits it for a valid v2 entry without a known category.
An old client will reject the full search response. Keep this wire field required and return Uncategorized.
There was a problem hiding this comment.
The agreed format requires an absent category for an uncategorized v2 entry. I kept the field optional as the plan requires.
| const cliRegistration = loadedPlugin?.handle.cli.registration; | ||
| const identity = | ||
| loadedPlugin === undefined ? identities.get(row.id) : undefined; | ||
| const catalogMetadata = installedCatalogMetadata(row); |
There was a problem hiding this comment.
🚨 slopcop/review — Plugin lists parse the same marketplace once per plugin
High: Each catalog plugin causes one database read and one full manifest parse on every plugin list request.
A valid 545 KB manifest took about 31 ms per parse here. Repeated work for 256 plugins took 7.94 seconds.
Load each marketplace once per list call. Parse it once and index its entries before this row map.
There was a problem hiding this comment.
Fixed in 12bc1d4. The list now groups installed rows by marketplace and parses each stored manifest once.
|
|
||
| export const pluginMarketplaceCategorySchema = z.object({ | ||
| id: pluginCatalogCategoryIdSchema, | ||
| displayName: z.string().min(1), |
There was a problem hiding this comment.
🚨 slopcop/review — Unbounded shared metadata can amplify one manifest into a huge response
High: Category and collection IDs, names, descriptions, counts, and membership counts have no practical limits.
A valid 935 KB manifest with one long category name produced a 230 MB search response for 256 plugins.
Add maximum lengths and counts in Zod and JSON Schema. Also guard the final response size.
There was a problem hiding this comment.
The agreed format and the registry schema define no category or collection limits. I did not add incompatible limits without a format decision.
| const TAG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u; | ||
| const GITHUB_LOGIN_PATTERN = /^[A-Za-z0-9](?:-?[A-Za-z0-9]){0,38}$/u; | ||
| const HOST_ICON_PATTERN = /^[A-Za-z][A-Za-z0-9]*$/u; | ||
| const HTTPS_URL_PATTERN = /^https:\/\//u; |
There was a problem hiding this comment.
🚨 slopcop/review — The public parser accepts malformed HTTPS values
Medium: This pattern accepts values such as https:// for author, registry, and git URLs.
The published JSON schema also accepts them. The server then rejects the same document with new URL.
Use real URL validation here and format: uri in the JSON schema. Add these cases to the parity test.
There was a problem hiding this comment.
Fixed in 12bc1d4. The v2 domain schema and published schema now reject malformed author, registry, and Git HTTPS URLs.
| iconUrl: data.iconUrl, | ||
| iconTinted: data.iconTinted, | ||
| category: data.category, | ||
| category: data.category ?? "Uncategorized", |
There was a problem hiding this comment.
🚨 slopcop/review — The app drops every new discovery field
High: This mapper keeps the category text only. It drops categoryId, screenshots, collections, and both dates.
The guide now says the detail page loads screenshots. The app cannot do that with this result type.
Add the fields to PluginCatalogSearchEntry and this mapper. Then render them, or remove the guide promise.
There was a problem hiding this comment.
PR B excludes Browse UI changes. PR D will map and render these fields. I kept this mapper outside the current scope.
| if (!("screenshots" in entry) || entry.screenshots === undefined) return []; | ||
| return entry.screenshots.map((declared) => { | ||
| const absolute = /^[A-Za-z][A-Za-z0-9+.-]*:/u.test(declared); | ||
| if (!absolute && base.kind !== "url") { |
There was a problem hiding this comment.
🚨 slopcop/review — Screenshot assets need one trusted delivery path
High: The public schema accepts relative screenshot files for every marketplace source.
This branch rejects those files for git and path marketplaces. It also returns arbitrary remote URLs directly to future browser clients.
Those URLs can name local or private hosts. Store, validate, and serve screenshots through bb, as the icon path does.
There was a problem hiding this comment.
The agreed design requires direct screenshot URLs and forbids a server fetch or proxy. A local manifest cannot produce a browser-safe HTTPS URL.
| entryId: string, | ||
| ): MarketplaceCollectionMembership[] { | ||
| if (manifest.schemaVersion !== 2) return []; | ||
| const entryIds = new Set(manifest.plugins.map((entry) => entry.id)); |
There was a problem hiding this comment.
🚨 slopcop/review — Collection lookup scans the full manifest for every plugin
High: Each call rebuilds the plugin set and scans every collection member. Search calls it before query filtering.
A valid 545 KB manifest added about 592 ms to one search with this work alone.
Build one membership map per parsed manifest. Then use an entry ID lookup for search and installed-plugin metadata.
There was a problem hiding this comment.
Fixed in 12bc1d4. The parser now builds one category and collection index for each parsed manifest.
| const MARKETPLACE_PATH_PREFIX = "/marketplace/v1/"; | ||
| const MARKETPLACE_PATHS = [ | ||
| { prefix: "/marketplace/v1/", objectPrefix: "" }, | ||
| { prefix: "/marketplace/v2/", objectPrefix: "v2/" }, |
There was a problem hiding this comment.
🚨 slopcop/review — The v2 asset route applies an unsafe icon policy to screenshots
Medium: V2 permits JPG and JPEG screenshots, but the MIME map has no image/jpeg fallback.
The route also gives every non-JSON object a one-year immutable cache. Screenshot names do not require a content hash.
Add JPEG MIME entries. Use revalidation for screenshots, or require content-addressed screenshot URLs.
There was a problem hiding this comment.
Fixed in 12bc1d4. The v2 route now supplies JPEG types and requires cache revalidation for v2 objects.
| }); | ||
| export type PluginCatalogAuthor = z.infer<typeof pluginCatalogAuthorSchema>; | ||
|
|
||
| export const pluginCatalogCollectionMembershipSchema = z.object({ |
There was a problem hiding this comment.
🚨 slopcop/review — Collection labels cannot reach clients
Medium: A v2 collection requires displayName, but this API keeps only its ID and rank.
No other catalog response exposes collection descriptors. A client cannot show a custom collection label.
Include the display name here, or expose the collection descriptors through a separate catalog contract.
There was a problem hiding this comment.
The required contract exposes collection membership as the collection ID and rank. A display name is outside PR B's agreed contract.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
This change teaches bb to read the new marketplace format. It adds categories, collections, screenshots, dates, v2 URLs, and a v1 fallback.
I found several issues that need work before this contract is safe and stable.
- High: The server can omit
category, so older SDK clients can reject the full search response. - High: The app drops every new discovery field, so the detail page cannot show the screenshots that the guide promises.
- High: Git and path marketplaces cannot use schema-valid relative screenshots.
- High: Future clients can receive screenshot URLs for local or private hosts. Serve these assets through bb, as icons are served.
- High: Plugin lists read and parse the same marketplace once per installed plugin. A valid case took 7.94 seconds.
- High: Collection lookup scans all members once per plugin. A valid search spent about 592 ms in this work.
- High: Unbounded shared metadata amplified a 935 KB manifest into a 230 MB search response.
- Medium: The domain and JSON schemas accept malformed HTTPS values that the server rejects.
- Medium: V2 screenshots inherit immutable icon caching, and valid JPG files can receive the wrong MIME type.
- Medium: The API discards collection display names, so clients cannot show custom labels.
The clean refactor is one parsed marketplace index. Search and installed-plugin lists should share its entry, category, and collection maps.
The legacy category projector also exists in two services. Move that policy into the same index or one shared helper.
I ran 11 Turbo test tasks. The domain, server contract, web, CLI, and server suites passed 2,990 tests.
I also tested the app with Doobie. Marketplace refresh succeeded, and the Browse Plugins page showed official and community entries.
The live v2 URL still returns 404, so this browser test exercised the v1 fallback. The nightly validator currently treats that 404 as success.
I left inline comments on each specific issue. I used a comment review only, with no approval or change-request action.
5f00e42 to
12bc1d4
Compare
|
🚨 SLOP COP 🚨 · I am the SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, and end-to-end behavior. |
| const SEMVER_NUMBER = String.raw`(?:0|[1-9]\d*|[xX*])`; | ||
| const SEMVER_PRERELEASE = String.raw`(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?`; | ||
| const SEMVER_BUILD = String.raw`(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?`; | ||
| const SEMVER_VERSION = String.raw`v?${SEMVER_NUMBER}(?:\.${SEMVER_NUMBER}(?:\.${SEMVER_NUMBER})?)?${SEMVER_PRERELEASE}${SEMVER_BUILD}`; |
There was a problem hiding this comment.
🚨 slopcop/review — The public range contract accepts values that refresh rejects
Medium: Values such as 1.x-alpha and 1.2+build pass this regex and the public JSON schema. semver.validRange() rejects them.
A publisher can pass schema checks, but bb then rejects the full marketplace refresh. Use the real semver validator and add negative parity cases.
There was a problem hiding this comment.
Fixed in cc32b20. The v2 public and domain contracts now reject partial prerelease ranges and accept valid build metadata.
| const HOST_ICON_PATTERN = /^[A-Za-z][A-Za-z0-9]*$/u; | ||
| const HTTPS_URL_PATTERN = /^https:\/\//u; | ||
| const ICON_URL_PATTERN = | ||
| /^(?:(?![A-Za-z][A-Za-z0-9+.-]*:)|(?=[Hh][Tt][Tt][Pp][Ss]:))[^\s]*\.(?:[Ss][Vv][Gg]|[Pp][Nn][Gg]|[Ww][Ee][Bb][Pp])(?:[?#][^\s]*)?$/u; |
There was a problem hiding this comment.
🚨 slopcop/review — The public icon contract accepts a malformed absolute URL
Medium: https:///icon.svg passes this pattern and the public JSON schema. URL parsing changes it to https://icon.svg/.
The server then rejects the missing path extension, so a schema-valid marketplace cannot refresh. Validate the HTTPS origin and parsed pathname here.
There was a problem hiding this comment.
Fixed in cc32b20. The v2 icon and screenshot patterns now require an HTTPS host and a valid path extension.
| if (marketplace === undefined) continue; | ||
| let manifest: MarketplaceManifest; | ||
| try { | ||
| manifest = parseMarketplaceManifestJson( |
There was a problem hiding this comment.
🚨 slopcop/review — Each plugin-list request reparses unchanged marketplace documents
Medium: Each list request reads and fully validates every marketplace that supplies an installed plugin.
The new grouping removes repeated work per plugin, but requests still repeat the same database reads and parses. Cache metadata by marketplace revision or hash.
There was a problem hiding this comment.
Fixed in cc32b20. Plugin lists now cache parsed manifests by stored JSON value and remove stale marketplace cache entries.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
This PR lets bb read and serve marketplace v2 documents. It adds categories, collections, screenshots, dates, and a v1 fallback.
I found three new issues on the current head.
- Medium: The public range schema accepts invalid values such as
1.x-alpha. The server rejects those values during refresh. - Medium: The public icon schema accepts
https:///icon.svg. The server later rejects the normalized URL. - Medium: Each plugin-list request reads and fully parses each used marketplace again, although the stored documents did not change.
One prior high-severity issue remains. A valid 0.91 MiB manifest can expand into a 225 MiB search response through an unbounded collection ID.
Direct screenshot URLs also remain a privacy risk for future clients. They permit tracking origins and HTTPS addresses on private networks.
The legacy category policy exists in two server services. One shared helper would prevent future drift.
The domain, server, and JSON validators also copy the same rules. Shared negative fixtures or generated schema would reduce contract drift.
I tested commit 12bc1d4802 directly. The domain and web Turbo suites passed all 268 tests.
I also used Doobie against the exact-head web server. The v2 schema returned HTTP 200 and declared schema version 2.
The local v2 object returned the expected HTTP 404 because the local R2 store had no live manifest. The route tests passed.
All current GitHub CI jobs passed or had an expected skipped state.
I used a comment review only. I did not approve the PR or request changes.
12bc1d4 to
cc32b20
Compare
|
🚨 SLOP COP 🚨 · I am SlopCop. I am now reviewing this pull request for security, code quality, performance, architecture, duplication, and end-to-end behavior. |
| existing !== undefined && | ||
| existing.sourceKind === "https" && | ||
| existing.manifestUrl === deps.marketplaceUrl | ||
| existing.manifestUrl === curatedManifestUrls.primary |
There was a problem hiding this comment.
🚨 slopcop/review — The v1-to-v2 upgrade discards the last good catalog
Medium: Existing installs store the curated v1 URL. On the first start after this upgrade, this comparison fails. The code then replaces the valid saved manifest with the two-entry bundled snapshot before any network refresh succeeds. If the machine is offline, all live-only catalog entries disappear until a later successful refresh.
Treat the paired curated v1 and v2 URLs as one logical source. Change the stored URL and clear its HTTP validators, but keep valid saved manifest JSON until refresh succeeds.
There was a problem hiding this comment.
I fixed this in e31753e. The URL upgrade now keeps a valid stored manifest and clears only the old HTTP validators. A new database test covers offline startup and a failed refresh.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
This PR lets bb read and serve marketplace v2 files. It adds categories, collections, screenshots, dates, and a v1 fallback.
I found one new upgrade bug on the current head.
- Medium: The first v1-to-v2 start replaces a valid saved catalog with the two-entry bundled snapshot before refresh succeeds. Offline users can lose all live-only catalog entries. I left an inline comment on the changed URL comparison.
Several earlier findings still remain.
- Unbounded category and collection data can block the server and greatly enlarge responses. A 300 KB invalid manifest took 5.1 seconds to reject. A valid 935 KB manifest produced a 230 MB response.
- The screenshot contract accepts relative repository assets, but git and path marketplaces reject them. Direct screenshot URLs also permit local or private HTTPS targets.
- V2 rejects some ranges that v1 accepts, including
==1and==1.2.
Two small performance issues also remain. An unchanged HTTPS manifest can parse twice per refresh. Cache cleanup can skip removed catalogs when no catalog plugin remains.
The domain schema, server parser, and public JSON schema repeat the same contract. Search and installed-plugin services also repeat metadata assembly.
One shared structural contract with server-only semantic checks would reduce this drift and remove duplicated policy.
The focused Turbo suites passed. One separate full run hit an unrelated timeline-test timeout under concurrent test load. All current GitHub CI checks passed.
I used Doobie on commit cc32b204bc. The public v2 schema returned HTTP 200 and schema version 2. The local v2 object returned the expected HTTP 404 because local R2 storage had no manifest.
The product plugin page loaded both official and community entries. I saw no new route, workflow, traversal, or icon-delivery security issue.
I used a comment review only. I did not approve the PR or request changes.
|
🚨 SLOP COP 🚨 · I am the Slop Cop. I am reviewing this pull request for security, code quality, performance, architecture, and end-to-end behavior. |
| const SEMVER_SET = String.raw`(?:\*|${SEMVER_VERSION}\s+-\s+${SEMVER_VERSION}|${SEMVER_COMPARATOR}(?:\s+${SEMVER_COMPARATOR})*|)`; | ||
|
|
||
| export const MARKETPLACE_SEMVER_RANGE_PATTERN = new RegExp( | ||
| String.raw`^\s*${SEMVER_SET}(?:\s*\|\|\s*${SEMVER_SET})*\s*$`, |
There was a problem hiding this comment.
🚨 slopcop/review — The semver expression can block the server main thread
High: The expression has overlapping whitespace branches and near-quadratic rejection time. I measured 3 ms at 1,000 spaces and 920 ms at 20,000 spaces.
A remote marketplace can send a much larger value within the 1 MiB manifest limit. A scheduled refresh then blocks the Node main thread.
Apply a small length guard before any expression check. Then use a bounded parser or a linear expression. Add a hostile whitespace regression test.
There was a problem hiding this comment.
I fixed this in bf287e9. The v2 parser rejects ranges above 256 characters before it evaluates the expression. The hostile whitespace test completed in 12 milliseconds locally.
| fallback: string | null; | ||
| } { | ||
| const url = new URL(configuredUrl); | ||
| if (url.pathname.endsWith("/marketplace/v1/marketplace.json")) { |
There was a problem hiding this comment.
🚨 slopcop/review — A custom v1 URL no longer names the first requested document
Medium: This branch rewrites every configured v1 suffix to a v2 sibling, including a private or test host.
If that sibling returns 401, 403, 500, invalid JSON, or a network error, bb never requests the configured v1 URL.
Rewrite only the known BB default URL. Preserve each explicit BB_MARKETPLACE_URL value. Add a custom-host test with a failing v2 sibling.
There was a problem hiding this comment.
I fixed this in bf287e9. Only the two known getbb.app URLs use the v2-first fallback pair. The server now requests each custom URL without a rewrite. A new test verifies this behavior.
| (value) => !INVALID_PARTIAL_PRERELEASE_PATTERN.test(value), | ||
| "prerelease ranges require three numeric version parts", | ||
| ); | ||
| const httpsUrlSchema = z.string().regex(HTTPS_URL_PATTERN); |
There was a problem hiding this comment.
🚨 slopcop/review — Version 2 rejects an inherited valid HTTPS form
Medium: Version 1 accepts uppercase HTTPS:// author, registry, and Git URLs through new URL(). This case-sensitive prefix rejects them in version 2.
The published schema says every version 1 field keeps its meaning. Reuse the version 1 URL rule and add cross-version fixtures.
There was a problem hiding this comment.
I fixed this in bf287e9. The parser and published schema now accept uppercase HTTPS schemes. The parity fixtures cover author, registry, and Git URLs. The v2 semver contract also accepts double-equals ranges.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
This PR lets bb read and serve the new marketplace format. It adds categories, collections, screenshots, dates, and a version 1 fallback.
I found one issue that must be fixed.
- High: The new semver expression has near-quadratic rejection time. A remote marketplace can block the Node main thread during refresh.
- High: Unbounded category and collection text can still enlarge a valid 935 KB manifest into a 230 MB search response.
- Medium: A custom version 1 URL changes to an unconfigured version 2 sibling. Many version 2 failures prevent the version 1 request.
- Medium: Version 2 rejects inherited valid forms. These forms include
==1,==1.2, and uppercaseHTTPS://URLs.
I left three new inline comments. An earlier inline comment already covers the response amplification issue.
The legacy category policy remains in two services. The domain parser, server parser, and public schema also repeat contract rules.
One shared parsed marketplace view would reduce this drift. One shared category helper would remove the duplicate policy.
The full server suite passed all 2,154 tests. The workers also passed 358 focused domain, contract, web, and marketplace tests.
I used Doobie against the exact commit. The Browse Plugins page loaded the temporary version 2 entry without console errors.
All current GitHub checks passed or had an expected skipped state.
I used a comment review only. I did not approve the PR or request changes.
|
🚨 |
| .refine((value) => value.range === undefined || value.tag === undefined, { | ||
| message: "range and tag are mutually exclusive", | ||
| }); | ||
| const nested = strict ? npm.strict() : npm; |
There was a problem hiding this comment.
🚨 slopcop/review — Keep v2 install source objects strict.
The v2 schema removes unknown npm, git, and outer source keys before server validation. I reproduced an entry with a wrong regsitry key. BB accepted it and selected the default registry. Similar key errors can change a package version, Git ref, subdirectory, or source. Keep only discovery metadata tolerant. Reject unknown install-source keys and add tests for common key errors.
There was a problem hiding this comment.
I will keep this behavior. The required v2 rule says that consumers must ignore unknown keys at every level. This rule includes install source objects. The parser still validates all known fields and required values. The tests verify unknown nested keys.
| : category === undefined | ||
| ? {} | ||
| : { categoryId: category.id, category: category.displayName }), | ||
| screenshots, |
There was a problem hiding this comment.
🚨 slopcop/review — Keep large detail data out of search responses.
The search response now returns screenshots, collections, and dates for every result. The app discards these fields in plugin-catalog-queries.ts. A large manifest can make each query response almost 1 MiB. The UI stores a result for each delayed query. Add a detail endpoint, or request this metadata only when a consumer needs it.
There was a problem hiding this comment.
I will keep these fields in search responses. The task requires search results to expose screenshots, dates, and collection membership. A detail endpoint changes the specified server contract and belongs outside this PR. The server caps plugins at 256 and screenshots at six per entry.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain-English summary
This change lets BB read version 2 plugin marketplace files. It adds categories, collections, screenshots, dates, a v2 web route, and a v1 fallback.
Findings
- High: The v2 parser removes unknown install-source keys before server validation. I reproduced
regsitryinstead ofregistry. BB accepted the entry and selected the default registry. A key error can select a different package version, Git ref, subdirectory, or registry. Keep install-source objects strict, and keep only discovery metadata tolerant. - Medium: Search returns screenshots, collections, and dates for every result. The app then discards these fields. A large manifest can make each delayed query response almost 1 MiB. Put this data behind a detail endpoint or an explicit option.
- Security note: The current app does not load the new screenshot URLs. Before a UI does, proxy and validate these assets through BB. Direct browser loads can disclose user network data or reach private HTTPS hosts.
- Architecture note: The PR copies legacy category normalization into
plugin-service. Use one shared projector so installed details and search results cannot differ. - Rollout note: Until v2 exists, each two-hour refresh makes an extra failed v2 request before the v1 fallback. Publish v2 before release, or store the fallback state.
Verification
- All 13 Turbo test tasks passed. The app suite reported 3,715 passing tests and four skips.
- All 10 Turbo type-check tasks passed.
- Doobie opened the new v2 route at the exact pull request SHA. The empty local bucket returned the expected JSON 404.
- A direct parser test returned
{"npm":{"package":"private-widget"}}after the invalid registry key.
The source parser issue needs a fix before merge. I left a comment review. I did not approve the pull request or request changes.
Keep stored v2 catalogs after a transient 404. Match the registry schema and expose collection data.
21d8a25 to
79939af
Compare
The new marketplace response fields change the bundled declarations.
Human comments
What was wrong
The server accepted only strict marketplace v1 documents. The public site also exposed only the v1 R2 object path.
What changed
How you verified
Fixes #