From 1df0805d727b911b037b838e0a1f59a67d6d9a94 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 27 Jul 2026 20:25:04 +0800 Subject: [PATCH] fix: configure TINYBIRD_URL for audit logs in workflows and server (#2465) * fix: configure TINYBIRD_URL for workflows audit logs Workflows was using Tinybird client without specifying baseUrl, causing it to default to production Tinybird API instead of using the configured TINYBIRD_URL (e.g., tinybird-local for development). This caused 'Unable to ingest to audit_log__v0: Unauthorized' errors because the local token was being sent to production Tinybird. Changes: - Added TINYBIRD_URL to env.ts schema (defaults to production API) - Updated audit-log.ts to pass baseUrl to Tinybird constructor This fixes notifications for private-location monitors by enabling audit log ingestion, which is required for status updates to succeed. * ci: apply automated fixes * fix: configure TINYBIRD_URL for server audit logs Server had the same issue as workflows - using Tinybird client without specifying baseUrl, causing it to default to production Tinybird API instead of using the configured TINYBIRD_URL. Changes: - Added TINYBIRD_URL to env.ts schema (defaults to production API) - Updated audit-log.ts to pass baseUrl to Tinybird constructor This ensures server connects to the correct Tinybird instance (e.g., tinybird-local for development). * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- apps/server/src/env.ts | 1 + apps/server/src/utils/audit-log.ts | 5 ++++- apps/workflows/src/env.ts | 1 + apps/workflows/src/utils/audit-log.ts | 5 ++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/server/src/env.ts b/apps/server/src/env.ts index e26c5019..12ee5b4d 100644 --- a/apps/server/src/env.ts +++ b/apps/server/src/env.ts @@ -7,6 +7,7 @@ export const env = createEnv({ UNKEY_API_ID: z.string().min(1), UNKEY_TOKEN: z.string().min(1), TINY_BIRD_API_KEY: z.string().min(1), + TINYBIRD_URL: z.string().default("https://api.tinybird.co"), UPSTASH_REDIS_REST_URL: z.string().min(1), UPSTASH_REDIS_REST_TOKEN: z.string().min(1), FLY_REGION: z.enum(monitorRegions), diff --git a/apps/server/src/utils/audit-log.ts b/apps/server/src/utils/audit-log.ts index 6c659698..100672d3 100644 --- a/apps/server/src/utils/audit-log.ts +++ b/apps/server/src/utils/audit-log.ts @@ -2,6 +2,9 @@ import { AuditLog, Tinybird } from "@openstatus/tinybird"; import { env } from "@/env"; -const tb = new Tinybird({ token: env.TINY_BIRD_API_KEY }); +const tb = new Tinybird({ + token: env.TINY_BIRD_API_KEY, + baseUrl: env.TINYBIRD_URL, +}); export const checkerAudit = new AuditLog({ tb }); diff --git a/apps/workflows/src/env.ts b/apps/workflows/src/env.ts index fe6fd712..f95178e9 100644 --- a/apps/workflows/src/env.ts +++ b/apps/workflows/src/env.ts @@ -15,6 +15,7 @@ export const env = () => DATABASE_AUTH_TOKEN: z.string().prefault(""), RESEND_API_KEY: z.string().prefault(""), TINY_BIRD_API_KEY: z.string().prefault(""), + TINYBIRD_URL: z.string().prefault("https://api.tinybird.co"), QSTASH_TOKEN: z.string().prefault(""), SCREENSHOT_SERVICE_URL: z.string().prefault(""), TWILLIO_AUTH_TOKEN: z.string().prefault(""), diff --git a/apps/workflows/src/utils/audit-log.ts b/apps/workflows/src/utils/audit-log.ts index 6ee3bdd8..2406ee92 100644 --- a/apps/workflows/src/utils/audit-log.ts +++ b/apps/workflows/src/utils/audit-log.ts @@ -2,6 +2,9 @@ import { AuditLog, Tinybird } from "@openstatus/tinybird"; import { env } from "../env"; -const tb = new Tinybird({ token: env().TINY_BIRD_API_KEY }); +const tb = new Tinybird({ + token: env().TINY_BIRD_API_KEY, + baseUrl: env().TINYBIRD_URL, +}); export const checkerAudit = new AuditLog({ tb }); -- 2.51.2