From 0f4fad2ea78cdc5a0fa6fab51844870d5eb4a276 Mon Sep 17 00:00:00 2001 From: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 22 Oct 2026 01:36:00 -0400 Subject: [PATCH] test(config): pin normalizeBlunderbuss' non-Error parseDuration arm and v8-ignore it for the bundle parseDuration throws only Error, so the non-Error alternate of the blunderbuss.delay catch in normalizeBlunderbuss is unreachable from dist/index.js. Drive it from a unit test that spies parseDuration to throw a string, exactly as configSweep.test.ts does for sweep.lookback, and give the alternate the same v8 ignore hint that arm carries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- __tests__/utils/configBlunderbussDelay.test.ts | 16 ++++++++++++++++ dist/index.js | 3 ++- src/utils/config.ts | 3 ++- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 __tests__/utils/configBlunderbussDelay.test.ts diff --git a/__tests__/utils/configBlunderbussDelay.test.ts b/__tests__/utils/configBlunderbussDelay.test.ts new file mode 100644 index 0000000..b8f6c20 --- /dev/null +++ b/__tests__/utils/configBlunderbussDelay.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it, vi } from 'vitest' + +import { parseProwConfig } from '../../src/utils/config' +import * as duration from '../../src/utils/duration' + +vi.mock('../../src/utils/duration', { spy: true }) + +describe('normalizeBlunderbuss', () => { + it('stringifies a non-Error thrown while parsing blunderbuss.delay', () => { + vi.mocked(duration.parseDuration).mockImplementationOnce(() => { + throw 'clock skew' // eslint-disable-line no-throw-literal + }) + + expect(() => parseProwConfig('x', 'blunderbuss:\n delay: 1h\n')).toThrow('x: clock skew') + }) +}) diff --git a/dist/index.js b/dist/index.js index 51090d7..1e6b9b5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -41210,7 +41210,8 @@ function normalizeBlunderbuss(source, raw) { ms = parseDuration(raw.delay, 'blunderbuss.delay'); } catch (e) { - throw new Error(`${source}: ${e instanceof Error ? e.message : e}`); + // parseDuration throws only Error + throw new Error(`${source}: ${e instanceof Error ? e.message : /* v8 ignore next -- non-Error arm unreachable from dist/index.js; configBlunderbussDelay.test.ts drives it */ e}`); } if (ms > maxBlunderbussDelayMs) { throw new Error(`${source}: blunderbuss.delay must not be longer than 24h`); diff --git a/src/utils/config.ts b/src/utils/config.ts index 512bfc5..bf7dba5 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -615,7 +615,8 @@ function normalizeBlunderbuss(source: string, raw: unknown): BlunderbussConfig { ms = parseDuration(raw.delay, 'blunderbuss.delay') } catch (e) { - throw new Error(`${source}: ${e instanceof Error ? e.message : e}`) + // parseDuration throws only Error + throw new Error(`${source}: ${e instanceof Error ? e.message : /* v8 ignore next -- non-Error arm unreachable from dist/index.js; configBlunderbussDelay.test.ts drives it */ e}`) } if (ms > maxBlunderbussDelayMs) { throw new Error(`${source}: blunderbuss.delay must not be longer than 24h`)