-
Notifications
You must be signed in to change notification settings - Fork 0
Ship feed-first public Tests with durable preview enrichment #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { requireAuthorizedUser } from "@/lib/auth/authorization"; | ||
| import { appendAuditEvent } from "@/lib/data/audit"; | ||
| import { retryShowcaseEnrichment } from "@/lib/data/showcase-enrichment"; | ||
| import { apiErrorResponse } from "@/lib/http/api"; | ||
| import { secureJson } from "@/lib/security/http"; | ||
| import { enforceRateLimit } from "@/lib/security/rate-limit"; | ||
|
|
||
| export async function POST( | ||
| request: Request, | ||
| context: { params: Promise<{ id: string }> }, | ||
| ) { | ||
| try { | ||
| const { identity, user } = await requireAuthorizedUser(request); | ||
| await enforceRateLimit(identity.subject, { | ||
| action: "showcase-enrichment-retry", | ||
| limit: 10, | ||
| windowMs: 24 * 60 * 60 * 1000, | ||
| }); | ||
| const { id } = await context.params; | ||
| const retry = await retryShowcaseEnrichment(id, user.id); | ||
| if (!retry) { | ||
| return secureJson( | ||
| { error: "No failed automated preview is available to retry." }, | ||
| { status: 409 }, | ||
| ); | ||
| } | ||
| await appendAuditEvent({ | ||
| actorUserId: user.id, | ||
| entityType: "showcase", | ||
| entityId: id, | ||
| action: "showcase.enrichment_retried", | ||
| metadata: { dispatchDeferred: retry.dispatchDeferred }, | ||
| }); | ||
| return secureJson({ retry }); | ||
| } catch (error) { | ||
| return apiErrorResponse(error); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { requireAuthorizedUser } from "@/lib/auth/authorization"; | ||
| import { appendAuditEvent } from "@/lib/data/audit"; | ||
| import { retryShowcaseProcessing } from "@/lib/data/showcase-processing"; | ||
| import { apiErrorResponse } from "@/lib/http/api"; | ||
| import { secureJson } from "@/lib/security/http"; | ||
| import { enforceRateLimit } from "@/lib/security/rate-limit"; | ||
|
|
||
| export async function POST( | ||
| request: Request, | ||
| context: { params: Promise<{ id: string }> }, | ||
| ) { | ||
| try { | ||
| const { identity, user } = await requireAuthorizedUser(request); | ||
| await enforceRateLimit(identity.subject, { | ||
| action: "showcase-processing-retry", | ||
| limit: 20, | ||
| windowMs: 24 * 60 * 60 * 1000, | ||
| }); | ||
| const { id } = await context.params; | ||
| const processing = await retryShowcaseProcessing(id, user.id); | ||
| await appendAuditEvent({ | ||
| actorUserId: user.id, | ||
| entityType: "showcase", | ||
| entityId: id, | ||
| action: | ||
| processing.outcome === "ready" | ||
| ? "showcase.processing_retry_completed" | ||
| : processing.outcome === "blocked" | ||
| ? "showcase.processing_retry_blocked" | ||
| : "showcase.processing_retry_pending", | ||
| metadata: { | ||
| outcome: processing.outcome, | ||
| scannedArtifactCount: processing.scannedArtifactIds.length, | ||
| }, | ||
| }); | ||
| return secureJson({ processing }); | ||
| } catch (error) { | ||
| return apiErrorResponse(error); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Publication record can claim an automated preview was scheduled when none exists
When scheduling the automated preview fails outright, the publication record is written as if the Test were preview-eligible and merely delayed (
enrichment = { dispatchDeferred: true, eligible: true, ... }atapp/api/showcases/[id]/publish/route.ts:42-46), so the audit trail and the response claim a preview is coming for Tests that will never have one.Impact: Operators reading publication records, and the contributor reading the publish response, are told an automated preview is pending for submissions that are not eligible for one.
Why the catch branch cannot know eligibility
scheduleShowcaseEnrichment(lib/data/showcase-enrichment.ts:38-69) already swallows queue-dispatch failures internally and returns{ dispatchDeferred: true, eligible: true }in that case. The only way it throws is whenensureShowcaseEnrichmentitself fails (for example a database error) — at which point noshowcase_enrichmentsrow exists and eligibility is unknown: the Test may have no compatible source ZIP at all.Hard-coding
eligible: truein the route's catch therefore reports an eligibility the code never determined. Reportingeligible: false(or a distinctunknownmarker) would keep the record honest; the scheduled reconciliation sweep still creates and dispatches the row later if the submission really is eligible.Was this helpful? React with 👍 or 👎 to provide feedback.