Repository navigation
Staff hub for featured collections - #8522
Prospector wants to merge 7 commits into
Conversation
Pull request changelogAppAddedChangedDeprecatedRemovedFixedSecurityWebsiteAddedChangedDeprecatedRemovedFixedSecurityHostingAddedChangedDeprecatedRemovedFixedSecurity |
|
Tick the box to add this pull request to the merge queue (same as
|
[Medium impact] The changes affect staff collection workflows and project data returned by the API. Fix private creation and shared collection overwrites before merging.
|
| if (input.status !== 'listed') { | ||
| try { | ||
| await client.labrinth.collections.edit(collection.id, { status: input.status }) | ||
| } catch (error) { | ||
| warnings.push(`Could not save visibility. ${collectionErrorMessage(error)}`) | ||
| } |
There was a problem hiding this comment.
Private collections start public
Choosing Private when creating a POTW collection still sends its projects to collections.create, which always creates a listed collection. Anyone can find it through the Modrinth account's collections and read its contents before the later visibility update. If that update fails, the collection stays public because the error only adds a warning.
Accept and save the chosen visibility in the creation request, before exposing any contents.
How this was verified: Collection creation commits Listed with the selected projects, and anonymous collection reads allow listed collections before the separate visibility update.
Knowledge Base Used: Backend API and authentication
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/frontend/src/components/ui/moderation/StaffCollectionCreateModal.vue
Line: 338-343
Comment:
**Private collections start public**
Choosing Private when creating a POTW collection still sends its projects to `collections.create`, which always creates a listed collection. Anyone can find it through the Modrinth account's collections and read its contents before the later visibility update. If that update fails, the collection stays public because the error only adds a warning.
Accept and save the chosen visibility in the creation request, before exposing any contents.
**How this was verified:** Collection creation commits `Listed` with the selected projects, and anonymous collection reads allow listed collections before the separate visibility update.
**Knowledge Base Used:** [Backend API and authentication](https://app.greptile.com/-/switch-tenant?tenant=modrinth&next=%2Fcustom-context%2Fknowledge-base%2Fmodrinth%2Fcode%2F-%2Fdocs%2Fbackend-api-auth.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| mutationFn: async (collection: Labrinth.Collections.Collection) => { | ||
| const projects = nextProjects(collection) | ||
| await client.labrinth.collections.edit(collection.id, { new_projects: projects }) |
There was a problem hiding this comment.
Staff changes overwrite each other
toggleProject replaces the whole collection using the list loaded by that page. If two moderators open different projects and add them to the same collection, the second save can remove the first moderator's addition. This can happen even when the saves happen one after another, since the second page still holds the old list.
The new add/remove helpers use the same read-then-replace pattern. Add server-side operations that change only the requested project IDs, or reject edits based on an outdated collection.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/frontend/src/components/ui/moderation/ProjectFeatureButton.vue
Line: 189-191
Comment:
**Staff changes overwrite each other**
`toggleProject` replaces the whole collection using the list loaded by that page. If two moderators open different projects and add them to the same collection, the second save can remove the first moderator's addition. This can happen even when the saves happen one after another, since the second page still holds the old list.
The new add/remove helpers use the same read-then-replace pattern. Add server-side operations that change only the requested project IDs, or reject edits based on an outdated collection.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| let refresh_projects = featured_project_cache_ids( | ||
| collection_item.status, | ||
| collection_item.flags, | ||
| &collection_item.projects, | ||
| new_collection.status.unwrap_or(collection_item.status), | ||
| new_collection | ||
| .collection_flags | ||
| .unwrap_or(collection_item.flags), | ||
| &next_projects, |
There was a problem hiding this comment.
Featured status can stay stale
The refresh list uses collection_item, which was read before the transaction. A concurrent edit can add a project that this request never sees. For example, one request reads an empty featured collection, another adds a project, and the first then makes the collection private. The first request clears no project caches, so a project cached between those saves keeps the collection in featured_in.
Read the current collection and its members under a shared write lock before changing them and calculating which caches to clear.
Knowledge Base Used: Backend data storage
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/labrinth/src/routes/v3/collections.rs
Line: 510-518
Comment:
**Featured status can stay stale**
The refresh list uses `collection_item`, which was read before the transaction. A concurrent edit can add a project that this request never sees. For example, one request reads an empty featured collection, another adds a project, and the first then makes the collection private. The first request clears no project caches, so a project cached between those saves keeps the collection in `featured_in`.
Read the current collection and its members under a shared write lock before changing them and calculating which caches to clear.
**Knowledge Base Used:** [Backend data storage](https://app.greptile.com/-/switch-tenant?tenant=modrinth&next=%2Fcustom-context%2Fknowledge-base%2Fmodrinth%2Fcode%2F-%2Fdocs%2Fbackend-data-storage.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Frontend previewsLast deployed commit is 7593efa405a96625286d2cfb4fe6e486d0e015d2 Persistent
Latest commit
|
No description provided.