From fa5a7d0c1ee056fefb0d2d5f8f19730a62d6d613 Mon Sep 17 00:00:00 2001 From: "posthog-eu[bot]" <226701856+posthog-eu[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 05:27:44 +0000 Subject: [PATCH] fix(cli): stop error tracking for missing bundle versions Throw CliUserError instead of a plain Error when a named bundle version is not found, so error tracking skips it. Move the app id and version out of the message and into the CliUserError context, so one problem stays one issue instead of one per version string. Covers `getVersionData` (used by channel set, bundle delete, bundle cleanup) and both throws in `deleteAppVersion`. Generated-By: PostHog Code Task-Id: 6571dd73-5da0-4970-a26a-9bc5bef6449a --- cli/src/api/versions.ts | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/cli/src/api/versions.ts b/cli/src/api/versions.ts index 965f22798c..fc7d47fc02 100644 --- a/cli/src/api/versions.ts +++ b/cli/src/api/versions.ts @@ -2,6 +2,7 @@ import type { SupabaseClient } from '@supabase/supabase-js' import type { Database } from '../types/supabase.types' import { log } from '@clack/prompts' import { Table } from '@sauber/table' +import { CliUserError } from '../shared/cli-user-error' import { formatError, getHumanDate, invokeCapgoCliApi, readCapgoCliApiErrorPayload } from '../utils' import { checkVersionNotUsedInChannel } from './channels' @@ -80,10 +81,13 @@ export async function deleteAppVersion( .eq('name', bundle) if (delAppSpecVersionError) { - const message = `App version ${appid}@${bundle} not found in database` if (!silent) - log.error(message) - throw new Error(`${message}: ${formatError(delAppSpecVersionError)}`) + log.error(`App version ${appid}@${bundle} not found in database`) + throw new CliUserError('App version not found in database', { + appId: appid, + version: bundle, + detail: formatError(delAppSpecVersionError), + }) } return } @@ -99,10 +103,13 @@ export async function deleteAppVersion( supaAnon, }) if (error) { - const message = `App version ${appid}@${bundle} not found in database` if (!silent) - log.error(message) - throw new Error(`${message}: ${formatError(error)}`) + log.error(`App version ${appid}@${bundle} not found in database`) + throw new CliUserError('App version not found in database', { + appId: appid, + version: bundle, + detail: formatError(error), + }) } } @@ -225,10 +232,13 @@ export async function getVersionData( const all = await getActiveAppVersions(apikey, appid, options) const versionData = all.find(row => row.name === bundle) if (!versionData) { - const message = `App version ${appid}@${bundle} doesn't exist` + // A named bundle that is not in the active list is a user typo or a version + // that was never uploaded, not a CLI crash. Throw a CliUserError so error + // tracking skips it, and keep the app id and version in `context` (not the + // message) so one problem stays one issue instead of one per version string. if (!silent) - log.error(message) - throw new Error(message) + log.error(`App version ${appid}@${bundle} doesn't exist`) + throw new CliUserError('App version doesn\'t exist', { appId: appid, version: bundle }) } return versionData }