-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: surveys validate conditions #28711
Conversation
@@ -755,7 +759,7 @@ def summarize_responses(self, request: request.Request, **kwargs): | |||
|
|||
survey = self.get_object() | |||
|
|||
cache_key = f'summarize_survey_responses_{self.team.pk}_{self.kwargs["pk"]}' | |||
cache_key = f"summarize_survey_responses_{self.team.pk}_{self.kwargs['pk']}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit linter did that so I guess its safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR adds validation for survey conditions to prevent runtime errors, specifically addressing a Sentry-reported AttributeError where string values were being incorrectly passed instead of dictionaries.
- Added validation in
posthog/api/survey.py
to ensure survey conditions are provided as dictionary objects - Fixed potential AttributeError when string values were passed instead of dictionaries for survey conditions
- Updated survey response summarization cache key formatting for better consistency
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
I think we probably need a similar check here? Line 561 in 75a2b82
|
I don't think so since those are called manually. |
@pauldambra adding you master of djangos so you double check my comment here. |
@marandaneto @ioannisj looks like the conditions definition is and in the validator
so i think can definitely be None |
if value is None: | ||
return value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this makes the return type dict | None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surgical 👨⚕️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the discussion I think this should be 👍
Problem
https://posthog.sentry.io/issues/6294642235/?alert_rule_id=15777369&alert_type=issue¬ification_uuid=1392b11e-fcc6-4661-9fb7-ca780439ee5e&project=1899813
Changes
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Does this work well for both Cloud and self-hosted?
How did you test this code?