Skip to content

fix(workflow_engine): Make UniqueConditionQuery hashable with list filters #93618

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

seer-by-sentry[bot]
Copy link
Contributor

Fixes SENTRY-41GH. The issue was that: UniqueConditionQuery used as dictionary key contains unhashable list in filters field, causing TypeError.

  • Converts list of dicts to tuple of frozensets for filters in UniqueConditionQuery to make it hashable.
  • Adds tests to ensure UniqueConditionQuery is hashable with and without filters, and that filters are properly converted.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 16, 2025
Copy link

codecov bot commented Jun 16, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
26548 1 26547 223
View the top 1 failed test(s) by shortest run time
tests.sentry.workflow_engine.processors.test_delayed_workflow.TestDelayedWorkflowQueries::test_unique_condition_query_hashable_with_filters
Stack Traces | 3.3s run time
#x1B[1m#x1B[.../workflow_engine/processors/test_delayed_workflow.py#x1B[0m:378: in test_unique_condition_query_hashable_with_filters
    dc_with_filters = self.create_data_condition(
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:634: in create_data_condition
    return Factories.create_data_condition(
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1.../x64/lib/python3.13/contextlib.py#x1B[0m:85: in inner
    return func(*args, **kwds)
#x1B[1m#x1B[.../sentry/testutils/factories.py#x1B[0m:2190: in create_data_condition
    return DataCondition.objects.create(condition_group=condition_group, **kwargs)
#x1B[1m#x1B[.../sentry/silo/base.py#x1B[0m:158: in override
    return original_method(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.13.../db/models/manager.py#x1B[0m:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
#x1B[1m#x1B[.../sentry/silo/base.py#x1B[0m:158: in override
    return original_method(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.13.../db/models/query.py#x1B[0m:663: in create
    obj.save(force_insert=True, using=self.db)
#x1B[1m#x1B[.../sentry/silo/base.py#x1B[0m:158: in override
    return original_method(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.13.../db/models/base.py#x1B[0m:902: in save
    self.save_base(
#x1B[1m#x1B[.../sentry/silo/base.py#x1B[0m:158: in override
    return original_method(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.13.../db/models/base.py#x1B[0m:988: in save_base
    pre_save.send(
#x1B[1m#x1B[.../testutils/pytest/stale_database_reads.py#x1B[0m:99: in send
    return old_send(self, sender, **named)
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/dispatch/dispatcher.py#x1B[0m:189: in send
    response = receiver(signal=self, sender=sender, **named)
#x1B[1m#x1B[.../workflow_engine/models/data_condition.py#x1B[0m:271: in enforce_comparison_schema
    enforce_data_condition_json_schema(instance)
#x1B[1m#x1B[.../workflow_engine/models/data_condition.py#x1B[0m:266: in enforce_data_condition_json_schema
    raise ValidationError(f"Invalid config: {e.message}")
#x1B[1m#x1B[31mE   jsonschema.exceptions.ValidationError: Invalid config: {'field': 'value1'} is not valid under any of the given schemas#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants