Repository navigation
Conversation
Pull request changelogAppAddedChangedDeprecatedRemovedFixedSecurityWebsiteAddedChangedDeprecatedRemovedFixedSecurityHostingAddedChangedDeprecatedRemovedFixedSecurity |
[High impact] Project changes across the API can now trigger model-backed moderation scans. Fix the interrupted upload work, unused model answers, changing run modules, and supported-image failures before merging.
|
| for state in &self.states { | ||
| crate::workflow::project_flag::reconcile_project_flags( | ||
| temporal, | ||
| state.data.inner.id.into(), | ||
| ) | ||
| .await | ||
| .map_err(|error| eyre!(error)) | ||
| .wrap_internal_err("dispatching project flag reconciliation")?; |
There was a problem hiding this comment.
If Temporal is unavailable during an upload, PreparedMutations::commit returns an error after the database transaction has committed. The caller then skips publish_new_files and the search update. Users see a failed upload even though the version exists, and its files miss their scan request.
Record reconciliation work durably with the mutation, then send it separately so a Temporal failure cannot interrupt the remaining upload steps.
Knowledge Base Used:
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/labrinth/src/routes/v3/projects/mutation.rs
Line: 524-531
Comment:
**Saved uploads report failure**
If Temporal is unavailable during an upload, `PreparedMutations::commit` returns an error after the database transaction has committed. The caller then skips `publish_new_files` and the search update. Users see a failed upload even though the version exists, and its files miss their scan request.
Record reconciliation work durably with the mutation, then send it separately so a Temporal failure cannot interrupt the remaining upload steps.
**Knowledge Base Used:**
- [Project and version workflows](https://app.greptile.com/-/switch-tenant?tenant=modrinth&next=%2Fcustom-context%2Fknowledge-base%2Fmodrinth%2Fcode%2F-%2Fdocs%2Fbackend-project-version-workflows.md)
- [Background processing and synchronization](https://app.greptile.com/-/switch-tenant?tenant=modrinth&next=%2Fcustom-context%2Fknowledge-base%2Fmodrinth%2Fcode%2F-%2Fdocs%2Fbackend-background-processing.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| futures::try_join!( | ||
| image_scan::scan_project_images(ctx, project_id), | ||
| text_scan::scan_project_text(ctx, project_id), | ||
| )?; | ||
|
|
||
| if !ctx.state(|state| state.needs_reconcile) { | ||
| return Ok(()); |
There was a problem hiding this comment.
Model answers never affect flags
ReconcileProjectFlagsWorkflow::run finishes after caching model answers, without evaluating rules or updating project flags. Only the image and text scan functions read project_flag_scans; ProjectFlagEngine never reads these answers. With inference enabled, project edits therefore send paid model requests whose answers cannot affect moderation flags.
Connect the cached answers to rule evaluation and flag updates before treating reconciliation as complete.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/labrinth/src/workflow/project_flag/mod.rs
Line: 90-96
Comment:
**Model answers never affect flags**
`ReconcileProjectFlagsWorkflow::run` finishes after caching model answers, without evaluating rules or updating project flags. Only the image and text scan functions read `project_flag_scans`; `ProjectFlagEngine` never reads these answers. With inference enabled, project edits therefore send paid model requests whose answers cannot affect moderation flags.
Connect the cached answers to rule evaluation and flag updates before treating reconciliation as complete.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| let engine = engine | ||
| .with_module_snapshot() | ||
| .await | ||
| .wrap_err("loading project flag module snapshot")?; |
There was a problem hiding this comment.
Each batch loads the current modules rather than the modules used when the run started. If a moderator edits or deletes an imported module while a run is queued, later batches use different code or fail to import it. One run can then contain results from different rule implementations despite its fixed rule snapshot.
Save module scripts with the run snapshot and load that saved copy for every batch.
Knowledge Base Used: Background processing and synchronization
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/labrinth/src/queue/moderation/project_flag_run.rs
Line: 187-190
Comment:
**Run results use changing code**
Each batch loads the current modules rather than the modules used when the run started. If a moderator edits or deletes an imported module while a run is queued, later batches use different code or fail to import it. One run can then contain results from different rule implementations despite its fixed rule snapshot.
Save module scripts with the run snapshot and load that saved copy for every batch.
**Knowledge Base Used:** [Background processing and synchronization](https://app.greptile.com/-/switch-tenant?tenant=modrinth&next=%2Fcustom-context%2Fknowledge-base%2Fmodrinth%2Fcode%2F-%2Fdocs%2Fbackend-background-processing.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| matches!(content_type, "image/png" | "image/jpeg" | "image/webp"), | ||
| "decisions image must be PNG, JPEG, or WebP" | ||
| ); | ||
|
|
There was a problem hiding this comment.
scan_image_explicit rejects GIF and BMP, although project uploads accept both formats and project_images selects the original uploaded bytes. With infer_decisions enabled, a valid GIF icon or BMP gallery image therefore makes its scan fail and prevents the reconciliation pass from finishing successfully.
Convert supported uploads to a model-supported format before calling the model.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/labrinth/src/workflow/project_flag/model_scan.rs
Line: 184-187
Comment:
**Supported images fail scans**
`scan_image_explicit` rejects GIF and BMP, although project uploads accept both formats and `project_images` selects the original uploaded bytes. With `infer_decisions` enabled, a valid GIF icon or BMP gallery image therefore makes its scan fail and prevents the reconciliation pass from finishing successfully.
Convert supported uploads to a model-supported format before calling the model.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| public async createModule(body: SaveProjectFlagModuleRequest): Promise<void> { | ||
| return this.client.request<void>('/moderation/project-flag/modules', { |
There was a problem hiding this comment.
Saved module responses are hidden
createModule and updateModule declare Promise<void>, but both routes return a DBProjectFlagModule JSON object. The API-client guide requires response types to match backend responses directly. Return Promise<ProjectFlagModule> and use request<ProjectFlagModule> so callers can use the saved module without bypassing the types. This repository requirement must be satisfied before merging.
Context Used: packages/api-client/AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/api-client/src/modules/labrinth/project-flags/internal.ts
Line: 44-45
Comment:
**Saved module responses are hidden**
`createModule` and `updateModule` declare `Promise<void>`, but both routes return a `DBProjectFlagModule` JSON object. The API-client guide requires response types to match backend responses directly. Return `Promise<ProjectFlagModule>` and use `request<ProjectFlagModule>` so callers can use the saved module without bypassing the types. This repository requirement must be satisfied before merging.
**Context Used:** packages/api-client/AGENTS.md ([source](https://github.com/modrinth/code/blob/main/packages/api-client/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Frontend previewsLast deployed commit is 2b65c8d0928d7eea68a16551e504afd163cc9f04 Persistent
Latest commit
|
No description provided.