From 95042e1383a586e00291b7aef769f8e06ead3049 Mon Sep 17 00:00:00 2001 From: diced Date: Mon, 25 Aug 2025 15:03:43 -0700 Subject: [PATCH] fix: silently error out when no git sha #864 --- .github/ISSUE_TEMPLATE/bug.yml | 9 --------- src/lib/version.ts | 8 +++++++- src/server/routes/api/stats.ts | 3 ++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 45a21230..28a02598 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -3,15 +3,6 @@ description: Report a reproducible bug in Zipline title: 'Bug: [short description of the issue]' labels: ['bug'] body: - - type: checkboxes - id: agree - attributes: - label: Confirm bug report - description: Please make sure that this is a bug with Zipline and not with any external services. Dealing with reproducible bugs help us a ton when trying to fix them. Please check the following that apply to this report. - options: - - label: "✅ This bug is a Zipline bug and is reproducible" - - label: "❌ I am not sure if this is a Zipline bug (it may be due to a configuration, user error, or external service)" - - type: textarea id: what-happened attributes: diff --git a/src/lib/version.ts b/src/lib/version.ts index a38b1a84..af91247b 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -1,5 +1,8 @@ import { version } from '../../package.json'; import { execSync } from 'child_process'; +import { log } from './logger'; + +const logger = log('version'); export function gitSha() { const envValue = process.env.ZIPLINE_GIT_SHA; @@ -9,7 +12,10 @@ export function gitSha() { const commitHash = execSync('git rev-parse --short HEAD').toString().trim(); return commitHash; } catch (error) { - console.error('Error getting git commit hash:', error); + if (!(error instanceof Error)) return null; + + logger.warn('failed to get commit hash: ' + error.message); + logger.debug('failed to get commit hash', { error: JSON.stringify(error) }); return null; } } diff --git a/src/server/routes/api/stats.ts b/src/server/routes/api/stats.ts index 7247c817..d472e8b5 100755 --- a/src/server/routes/api/stats.ts +++ b/src/server/routes/api/stats.ts @@ -19,7 +19,8 @@ export default fastifyPlugin( server.get<{ Querystring: Query }>(PATH, { preHandler: [userMiddleware] }, async (req, res) => { if (!config.features.metrics) return res.forbidden('metrics are disabled'); - if (config.features.metrics.adminOnly && !isAdministrator(req.user.role)) return res.forbidden('admin only'); + if (config.features.metrics.adminOnly && !isAdministrator(req.user.role)) + return res.forbidden('admin only'); const { from, to, all } = req.query;