Skip to content

Commit d8ccdb0

Browse files
committed
feat(cli): include postmaster startup error in H002 output
- Added optional postmaster_startup_error field to StatsReset - Consistent with documented error handling strategy (graceful degradation) - Errors now captured in report output for visibility - Updated H002 schema to allow the new optional field
1 parent 86d1c74 commit d8ccdb0

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

cli/lib/checkup.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ export interface StatsReset {
136136
days_since_reset: number | null;
137137
postmaster_startup_epoch: number | null;
138138
postmaster_startup_time: string | null;
139+
/** Set when postmaster startup time query fails - indicates data availability issue */
140+
postmaster_startup_error?: string;
139141
}
140142

141143
/**
@@ -621,8 +623,10 @@ export async function getStatsReset(client: Client, pgMajorVersion: number = 16)
621623
: null;
622624

623625
// Get postmaster startup time separately (simple inline SQL)
626+
// This is supplementary data - errors are captured in output, not propagated
624627
let postmasterStartupEpoch: number | null = null;
625628
let postmasterStartupTime: string | null = null;
629+
let postmasterStartupError: string | undefined;
626630
try {
627631
const pmResult = await client.query(`
628632
select
@@ -637,16 +641,24 @@ export async function getStatsReset(client: Client, pgMajorVersion: number = 16)
637641
}
638642
} catch (err) {
639643
const errorMsg = err instanceof Error ? err.message : String(err);
640-
console.log(`[getClusterInfo] Error querying postmaster start time: ${errorMsg}`);
644+
postmasterStartupError = `Failed to query postmaster start time: ${errorMsg}`;
645+
console.log(`[getStatsReset] Warning: ${postmasterStartupError}`);
641646
}
642647

643-
return {
648+
const statsResult: StatsReset = {
644649
stats_reset_epoch: statsResetEpoch,
645650
stats_reset_time: statsResetTime,
646651
days_since_reset: daysSinceReset,
647652
postmaster_startup_epoch: postmasterStartupEpoch,
648653
postmaster_startup_time: postmasterStartupTime,
649654
};
655+
656+
// Only include error field if there was an error (keeps output clean)
657+
if (postmasterStartupError) {
658+
statsResult.postmaster_startup_error = postmasterStartupError;
659+
}
660+
661+
return statsResult;
650662
}
651663

652664
/**

reporter/schemas/H002.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
"stats_reset_time": { "type": ["string", "null"] },
8383
"days_since_reset": { "type": ["integer", "null"] },
8484
"postmaster_startup_epoch": { "type": ["number", "null"] },
85-
"postmaster_startup_time": { "type": ["string", "null"] }
85+
"postmaster_startup_time": { "type": ["string", "null"] },
86+
"postmaster_startup_error": { "type": "string" }
8687
}
8788
},
8889
"dbEntry": {

0 commit comments

Comments
 (0)