0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00

fix(correlation): fix recursion limit error if no steps provided (#6548)

Previously we would attempt to generate a response even though there
were no steps. There appears to be some code paths that blow up if this
happens, so instead we return as soon as we can in this case. This
appears to be the behaviour elsewhere also.

This resolves the sentry error found here:
https://sentry.io/organizations/posthog/issues/2718768248/
This commit is contained in:
Harry Waye 2021-10-19 15:38:36 +01:00 committed by GitHub
parent af876da5f0
commit 43de375d44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -441,6 +441,8 @@ class FunnelCorrelation:
correlation, e.g. "watched video"
"""
if not self._filter.entities:
return FunnelCorrelationResponse(events=[], skewed=False)
event_contingency_tables, success_total, failure_total = self.get_partial_event_contingency_tables()

View File

@ -334,6 +334,33 @@ class FunnelCorrelationTest(BaseTest):
],
)
def test_correlation_endpoint_request_with_no_steps_doesnt_fail(self):
"""
This just checks that we get an empty result, this mimics what happens
with other insight endpoints. It's questionable that perhaps this whould
be a 400 instead.
"""
self.client.force_login(self.user)
with freeze_time("2020-01-01"):
response = get_funnel_correlation_ok(
client=self.client,
team_id=self.team.pk,
request=FunnelCorrelationRequest(
events=json.dumps([]),
date_to="2020-01-14",
date_from="2020-01-01",
funnel_correlation_type=FunnelCorrelationType.PROPERTIES,
funnel_correlation_names=json.dumps(["$browser"]),
),
)
assert response == {
"is_cached": False,
"last_refresh": "2020-01-01T00:00:00Z",
"result": {"events": [], "skewed": False},
}
@pytest.fixture(autouse=True)
def clear_django_cache():