PostHog / PostHog/posthog

Bug: Marketing analytics dashboard crashes with "Unable to resolve field" when a Data Warehouse conversion goal references columns that don't exist on the table

Open
#49,073 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug feature/marketing-analytics
Dominant language
Python
Stars
39.9k
Forks
3.4k
Avg merge
6h 51m
Merged PRs (30d)
232

Description

Bug Description

Bug description

When a customer configures a Data Warehouse conversion goal for marketing analytics, the system allows saving the goal even if the schema_map field mappings (e.g., utm_campaign_name, utm_source_name) reference columns that don't exist on the selected data warehouse table.

This causes all three marketing analytics query runners to crash at query execution time with:
Unable to resolve field: utm_campaign

The error occurs because ConversionGoalProcessor.get_utm_expressions() generates a bare field reference (e.g., ast.Field(chain=["utm_campaign"])) against the DW table. When the resolver can't find that column on the table, the entire dashboard fails, not just the misconfigured goal.

The affected query runners are:

  • marketing_analytics_table_query_runner
  • marketing_analytics_aggregated_query_runner
  • non_integrated_conversions_table_query_runner

All three fail because the unified conversion goals CTE (ucg) UNION ALLs all conversion goal queries together, so one invalid goal breaks the entire query.

How to reproduce

  1. Link a data warehouse source (e.g., Postgres) that does NOT have utm_campaign / utm_source columns
  2. Create a conversion goal in marketing analytics settings using a table from that source (DataWarehouseNode type)
  3. Leave the schema_map field mappings at their defaults (utm_campaign_name: "utm_campaign", utm_source_name: "utm_source")
  4. Navigate to the marketing analytics dashboard

The dashboard will fail with "Unable to resolve field: utm_campaign".

Additional context

From: https://posthoghelp.zendesk.com/agent/tickets/51538 (moved to PostHog: https://us.posthog.com/project/2/support/tickets/53232)

The customer has Google Ads, Meta Ads, and TikTok Ads as native marketing sources (these work fine). They also have a conversion goal referencing a Postgres table — this is the goal causing the crash.

Potential areas for improvement:

  • Frontend validation: When configuring a DW conversion goal, validate that the schema_map columns actually exist on the selected table before allowing save
  • Backend resilience: In ConversionGoalProcessor.generate_cte_query(), validate column existence and skip or gracefully degrade the goal rather than letting the entire query fail
Debug info
Kind: bug

Target area: analytics

Report event: http://go/ticketByUUID/5b1e40e6-dbc9-450e-8c87-aa0daf5d772c

Session: https://us.posthog.com/project/sTMFPsFhdP1Ssg/replay/019c8ed1-2750-7389-aef5-77330c4008d7?t=1872

Exceptions: https://us.posthog.com/project/2/error_tracking?filterGroup=%7B%22type%22%3A%22AND%22%2C%22values%22%3A%5B%7B%22type%22%3A%22AND%22%2C%22values%22%3A%5B%7B%22key%22%3A%22%24session_id%22%2C%22value%22%3A%5B%22019c8ed1-2750-7389-aef5-77330c4008d7%22%5D%2C%22operator%22%3A%22exact%22%2C%22type%22%3A%22event%22%7D%5D%7D%5D%7D

Location: https://eu.posthog.com/project/39835/marketing?date_from=-30d&interval=week&compare=false&integration_sources=019c8ee3-3905-0000-49d4-ecc823eb3885%2C019b0484-2b61-0000-31f5-44af52b1cc81%2C019b045a-520b-0000-cf2f-7253ee0e5df9&chart_display_type=ActionsLineGraph&tile_column=cost

Persons-on-events mode for project: person_id_override_properties_on_events

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ConversionGoalProcessor.get_utm_expressions() and generate_cte_query(), then trace the marketing_analytics_table_query_runner, marketing_analytics_aggregated_query_runner, and non_integrated_conversions_table_query_runner paths. Reproduce the missing-column case with a DataWarehouseNode goal and verify that invalid schema_map references no longer crash the unified conversion-goals query or dashboard.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
analytics, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.