From ae1f0ade7d2917e88eaeb2898432028930a4eec8 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Fri, 31 Jul 2026 19:25:16 +0300 Subject: [PATCH] fix: treat uploads-from-forks as warnings, not errors When an open source repository is forked, and runs tests inside, the OIDC upload fails. This is a common-enough case, so instead of printing a scary error message, we should consider the upload "skipped". --- src/uploadReport.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/uploadReport.ts b/src/uploadReport.ts index 02b59cf..4de54a1 100644 --- a/src/uploadReport.ts +++ b/src/uploadReport.ts @@ -229,7 +229,8 @@ export type UploadOptions = { * * @returns {Promise} Promise that resolves to an upload result object: * - `{ status: 'success', reportUrl: string }` - Upload succeeded, includes web URL to view report - * - `{ status: 'skipped', reason: string }` - Upload was skipped (e.g., no access token) + * - `{ status: 'skipped', reason: string }` - Upload was skipped (e.g., no access token or the + * OIDC token belongs to a fork instead of the repository bound to the Flakiness project) * - `{ status: 'failed', error: string }` - Upload failed, includes error message * * @throws {Error} Only throws if `options.throwOnFailure` is true and upload fails. @@ -281,6 +282,11 @@ export async function uploadReport( const uploadResult = await upload.upload(); if (!uploadResult.success) { const errorMessage = uploadResult.message || 'Unknown upload error'; + const repositoryMismatchReason = oidcRepositoryMismatchReason(errorMessage); + if (repositoryMismatchReason !== undefined) { + logger.warn(`[flakiness.io] ⚠ Skipping upload: ${repositoryMismatchReason}`); + return { status: 'skipped', reason: repositoryMismatchReason }; + } logger.error(`[flakiness.io] ✕ Failed to upload: ${errorMessage}`); if (options?.throwOnFailure) throw new Error(`Flakiness upload failed: ${errorMessage}`); @@ -298,6 +304,15 @@ export async function uploadReport( } } +function oidcRepositoryMismatchReason(errorMessage: string): string | undefined { + const messageStart = 'OIDC token repository "'; + const messageMiddle = '" does not match flakiness project repository "'; + const messageStartIndex = errorMessage.indexOf(messageStart); + if (messageStartIndex === -1 || !errorMessage.includes(messageMiddle, messageStartIndex + messageStart.length)) + return undefined; + return errorMessage.slice(messageStartIndex).trim(); +} + class ReportUpload { private _report: FlakinessReport.Report; private _attachments: Attachment[];