Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(logs): quote numeric pipeline_id in otel etl logs filter (#47436)

Jordi Enricebafe8dd05bc
diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.test.ts b/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.test.ts
index 110ebbb387f..cddce409337 100644
--- a/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.test.ts
+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.test.ts
@@ -640,6 +640,28 @@ describe('OTEL filter translation', () => {
100"
`)
})
+
+ it('quotes a numeric etl pipeline_id so it compares as a string', () => {
+ // The replication "View logs" link puts pipeline_id in the `f` param as a
+ // number; JSON.parse keeps it numeric, so model that path here.
+ const filters = JSON.parse('{ "pipeline_id": 42 }')
+ expect(fmt(genDefaultQueryOtel(LogsTableName.ETL, filters))).toMatchInlineSnapshot(`
+ "-- Logs Preview Query (otel) ['etl_replication_logs']
+ select
+ id,
+ timestamp,
+ event_message
+ from
+ logs
+ where
+ source = 'etl_replication_logs'
+ and (log_attributes['pipeline_id'] = '42')
+ order by
+ timestamp desc
+ limit
+ 100"
+ `)
+ })
})
describe('otelTimestampToMicros', () => {
diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.ts b/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.ts
index 169d6db66f1..9e999f6e455 100644
--- a/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.ts
+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.ts
@@ -102,7 +102,9 @@ const SUPAVISOR_FILTERS: Record<string, SqlFilterEntry> = {
}
const ETL_FILTERS: Record<string, SqlFilterEntry> = {
...COMMON_FILTERS,
- pipeline_id: (value: string | number) => safeSql`${attr('pipeline_id')} = ${lit(value)}`,
+ // pipeline_id arrives as a number, but log_attributes values are strings, so
+ // compare as a string. A numeric literal here is a ClickHouse type error.
+ pipeline_id: (value: string | number) => safeSql`${attr('pipeline_id')} = ${lit(String(value))}`,
}
const col = (key: string, alias: SafeLogSqlFragment): SafeLogSqlFragment =>