:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(cdp): bound invocation severity query to the page date range (#81459)
Bryan Ciaraldi88aa3bccdfe3
diff --git a/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsx b/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsxindex e077a5aea3a1..6e8058dbd693 100644--- a/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsx+++ b/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsx@@ -784,25 +784,37 @@ async function fetchRunsPage(*/async function fetchProblemLevels(props: HogInvocationsLogicProps,+ filters: HogInvocationsFilters,ids: string[]): Promise<Record<string, 'warn' | 'error'>> {if (ids.length === 0) {return {}}const idClause = hogql.raw(`instance_id IN (${ids.map(escapeHogQLString).join(',')})`)+ // Lower-bound only: async failures (e.g. SES bounces) log after the invocation+ // finishes, so an upper bound could hide late problems. The lower bound keeps the+ // query off old log_entries partitions (older data is tiered to object storage) —+ // logs can't predate the invocations on the page, which are >= date_from.const severityQuery = hogql`SELECT instance_id, max(multiIf(lower(level) = 'error', 2, lower(level) = 'warn', 1, 0)) AS sevFROM log_entriesWHERE log_source = ${props.functionKind}AND log_source_id = ${props.id}+ AND timestamp >= {filters.dateRange.from}AND ${idClause}GROUP BY instance_idHAVING sev > 0`- const severityResponse = await api.queryHogQL(severityQuery, {- scene: 'HogInvocations',- productKey: 'pipeline_destinations',- })+ const severityResponse = await api.queryHogQL(+ severityQuery,+ {+ scene: 'HogInvocations',+ productKey: 'pipeline_destinations',+ },+ {+ filtersOverride: { date_from: filters.date_from },+ }+ )const levelByInvocationId: Record<string, 'warn' | 'error'> = {}for (const severityRow of severityResponse.results ?? []) {const [instanceId, sev] = severityRow as unknown as [string, number]@@ -1156,7 +1168,7 @@ export const hogInvocationsLogic = kea<hogInvocationsLogicType>([}let levelByInvocationId: Record<string, 'warn' | 'error'>try {- levelByInvocationId = await fetchProblemLevels(props, ids)+ levelByInvocationId = await fetchProblemLevels(props, values.filters, ids)} catch {// Leave levels as-is — the run statuses are still accurate.return values.runs