PostHog / posthog

🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
19.39k stars 1.13k forks source link

Bug Report: cohort breakdown crashes a trends query if breakdown limit is applied #23358

Open skoob13 opened 4 days ago

skoob13 commented 4 days ago

Bug Description

Bug description

When you select a few cohorts in the breakdown and apply a breakdown limit that is lower than the number of selected cohorts, the query crashes.

Screenshot 2024-07-01 at 14 15 13

How to reproduce

  1. Select two cohorts
  2. Set the limit to 1

Additional context

Query:

{
  "aggregation_group_type_index": null,
  "breakdownFilter": {
    "breakdown": [
      2,
      1
    ],
    "breakdown_group_type_index": null,
    "breakdown_hide_other_aggregation": null,
    "breakdown_histogram_bin_count": null,
    "breakdown_limit": 1,
    "breakdown_normalize_url": null,
    "breakdown_type": "cohort",
    "breakdowns": null
  },
  "compareFilter": null,
  "dateRange": null,
  "filterTestAccounts": false,
  "interval": "day",
  "kind": "TrendsQuery",
  "modifiers": null,
  "properties": [],
  "response": null,
  "samplingFactor": null,
  "series": [
    {
      "custom_name": null,
      "event": "$pageview",
      "fixedProperties": null,
      "kind": "EventsNode",
      "limit": null,
      "math": "total",
      "math_group_type_index": null,
      "math_hogql": null,
      "math_property": null,
      "name": "$pageview",
      "orderBy": null,
      "properties": null,
      "response": null
    }
  ],
  "trendsFilter": {
    "aggregationAxisFormat": "numeric",
    "aggregationAxisPostfix": null,
    "aggregationAxisPrefix": null,
    "breakdown_histogram_bin_count": null,
    "decimalPlaces": null,
    "display": "ActionsLineGraph",
    "formula": null,
    "hiddenLegendIndexes": null,
    "showLabelsOnSeries": null,
    "showLegend": false,
    "showPercentStackView": false,
    "showValuesOnSeries": false,
    "smoothingIntervals": 1,
    "yAxisScaleType": null
  }
}

Debug info

- [ ] PostHog Cloud, Debug information: [please copy/paste from https://us.posthog.com/settings/project-details#variables or https://eu.posthog.com/settings/project-details#variables]
- [ ] PostHog Hobby self-hosted with `docker compose`, version/commit: [please provide]
- [ ] PostHog self-hosted with Kubernetes (deprecated, see [`Sunsetting Kubernetes support`](https://posthog.com/blog/sunsetting-helm-support-posthog)), version/commit: [please provide]