One function

sort_and_filter_feature_segments in Flagsmith/flagsmith-engine

The author described this change as Fix TypeError when sorting feature segments (#91). It counts as a record because the check below fails on the code as it stood at 98b01781f and passes on 9f94ff995, with nothing else changed between the two runs.

Fix saved2022-02-03
Sharing licenceBSD-3-Clause · LICENSE.txt
Change size+3 1

What the code was meant to do, written into the code itself as a docstring

Feature segments in the django data model are associated with a segment and an environment we need to make sure we only get the feature segments for the environment we are serializing. :param feature_segments: queryset of django FeatureSegment model objects :param environment_api_key: the api key of the environment we are looking for :return: filtered list of django FeatureSegment model objects for the current environment only

The change

2020 )
2121
2222 # TODO: determine why this sorting is necessary
23- return sorted(feature_segments, key=lambda fs: (fs.feature, Reverser(fs.priority)))
23+ return sorted(
24+ feature_segments, key=lambda fs: (fs.feature_id, Reverser(fs.priority))
25+ )

The check that tells the two apart

failpass·tests/unit/django_transform/test_django_transform_filters.py::test_sort_and_filter_feature_segments

Check file tests/unit/django_transform/test_django_transform_filters.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it98b01781fd2d7ae9c24463cd31383c7195866bc8
Broken version dated2022-02-02
Moduleflag_engine.django_transform.filters
Units changedsort_and_filter_feature_segments
Fingerprint51e49e9675d7e083
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in Flagsmith/flagsmith-engine