From 407bba8b436103b1b351199722181eb43185b69f Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Mon, 28 Sep 2026 12:32:39 +0700 Subject: [PATCH] Keep GEO available before ingestion setup --- src/ingest.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ingest.ts b/src/ingest.ts index c696b76..9d2d781 100644 --- a/src/ingest.ts +++ b/src/ingest.ts @@ -32,7 +32,12 @@ function secureTokenMatch(supplied: string, configured: string): boolean { && timingSafeEqual(suppliedBuffer, configuredBuffer) } -function requireIngestionToken(request: FastifyRequest, configuredToken: string): void { +function requireIngestionToken(request: FastifyRequest, configuredToken: string | undefined): void { + if (!configuredToken) { + const error = new Error('GEO ingestion is not configured') as Error & { statusCode: number } + error.statusCode = 503 + throw error + } const suppliedToken = request.headers['x-ingestion-token'] if (typeof suppliedToken !== 'string' || !secureTokenMatch(suppliedToken, configuredToken)) { const error = new Error('Unauthorized GEO ingestion request') as Error & { statusCode: number } @@ -250,7 +255,6 @@ async function upsertReference(payload: ReferencePayload): Promise { const configuredToken = process.env.GEO_INGESTION_TOKEN - if (!configuredToken) throw new Error('GEO_INGESTION_TOKEN is required') app.post('/internal/ingest/catalog', async (request) => { requireIngestionToken(request, configuredToken)