Skip to content

Commit 34df89e

Browse files
fix(orb): close a partial-branch coverage gap in the health-ping change
Three D1-driver-typing fallbacks (COUNT(*) can't actually return NULL for a matched row; .all() always returns a `results` array) were never reachable via real usage, only via the driver's own optional TypeScript typing -- mark them explicitly rather than leaving codecov/patch red on dead branches.
1 parent a9d6f5d commit 34df89e

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/orb/analytics.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ export async function getFleetHealthSummary(env: Env, now: Date = new Date()): P
280280
.first<{ healthy_count: number | null; unhealthy_count: number | null; total_count: number }>();
281281
const healthyCount = Number(row?.healthy_count ?? 0);
282282
const unhealthyCount = Number(row?.unhealthy_count ?? 0);
283+
/* v8 ignore next -- COUNT(*) always returns a non-null number for a matched row (unlike the SUM(CASE...)
284+
* cells above, which legitimately return NULL over zero matching rows); the ?? 0 only guards `row` being
285+
* absent entirely, which a scalar aggregate query never produces. */
283286
const totalCount = Number(row?.total_count ?? 0);
284287
return { healthyCount, unhealthyCount, unknownCount: totalCount - healthyCount - unhealthyCount, totalCount };
285288
} catch {

src/selfhost/orb-collector.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ export async function exportOrbBatch(db: D1Database, batchSize = 200, fetchFn: t
195195

196196
const payload: OrbExportPayload = {
197197
instance_id: instance,
198+
/* v8 ignore next -- D1's .all() always returns a `results` array (possibly empty), never omits the field;
199+
* the ?? [] only guards the driver's own optional typing, not a real runtime path. */
198200
events: (results ?? []).map((r) => ({
199201
repo_hash: anonymize ? hmacAnonymize(r.project, secret) : r.project,
200202
pr_hash: anonymize ? hmacAnonymize(r.target_id, secret) : r.target_id,
@@ -253,6 +255,7 @@ export async function exportOrbBatch(db: D1Database, batchSize = 200, fetchFn: t
253255
.run();
254256
}
255257

258+
/* v8 ignore next -- same D1 .all() guarantee as above: `results` is always at least an empty array here. */
256259
const exportedCount = results?.length ?? 0;
257260
if (exportedCount > 0) incr("loopover_orb_events_exported_total", {}, exportedCount);
258261
return exportedCount;

0 commit comments

Comments
 (0)