PostHog / PostHog/posthog

[customer analytics] column_configurations LIST returns 500, breaking accounts saved views

Open
#68,909 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

GET /api/environments/:id/column_configurations — the endpoint backing accounts saved views — returns HTTP 500 in some environments, so saved views fail to load. The most likely cause is that the migration adding the properties JSON field to ColumnConfiguration hasn't been applied in the affected environment (the serializer selects properties, so a missing column raises UndefinedColumn → 500). A secondary suspect is a malformed stored filters/properties value. The fix is to verify/apply the migration and harden the serializer against malformed stored JSON.

Part of #68887.

Confidence: root cause is inferred from code; a server-side traceback for one of these 500s would confirm which cause it is.

Details for coding agents

Root cause (most likely)
Migration 1224_columnconfiguration_properties.py added the properties JSONField to ColumnConfiguration. If it isn't applied in an environment, the LIST query selecting posthog_columnconfiguration.properties fails with a Postgres UndefinedColumn and returns an unhandled 500. To confirm: SELECT properties FROM posthog_columnconfiguration LIMIT 1 in that environment — a "column does not exist" error confirms the missing migration.

Secondary suspect
A stored row whose filters/properties/order_by JSON can't be serialized in to_representation. Current code handles None/{}/lists, so no obvious crash if migrations are current — hence the migration is the stronger hypothesis.

Proposed fix

  1. Verify and apply the migration in the affected environment(s).
  2. Defensively guard to_representation against malformed stored JSON so one bad row can't 500 the whole list.

References

  • posthog/models/column_configuration.py:19 (properties field)
  • posthog/migrations/1224_columnconfiguration_properties.py (the migration)
  • posthog/api/column_configuration.py:68-71 (to_representation / validate_filters)
  • products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts (consumer — saved views)

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 posthog/migrations/1224_columnconfiguration_properties.py and posthog/models/column_configuration.py, then inspect posthog/api/column_configuration.py:68-71 and confirm the reported database error in the affected environment. Done means the column_configurations LIST endpoint no longer returns 500 with the migration applied, including when stored filters or properties are malformed.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python, typescript
Domain
api, backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.