Skip to content
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: ignore old versions when validating segment override limit #4618

Merged
merged 10 commits into from
Sep 12, 2024

Conversation

matthewelwell
Copy link
Contributor

Changes

Ensure that old versions aren't included when validating segment override limit.

How did you test this code?

Added tests.

@matthewelwell matthewelwell requested a review from a team as a code owner September 10, 2024 19:46
@matthewelwell matthewelwell requested review from zachaysan and removed request for a team September 10, 2024 19:46
Copy link

vercel bot commented Sep 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 12, 2024 8:09am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 8:09am
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 8:09am

@github-actions github-actions bot added the api Issue related to the REST API label Sep 10, 2024
…imits

# Conflicts:
#	api/tests/unit/features/versioning/test_unit_versioning_views.py
Copy link
Contributor

github-actions bot commented Sep 11, 2024

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-4618 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-4618 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-4618 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-4618 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-4618 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-4618 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Sep 11, 2024

Uffizzi Preview deployment-56144 was deleted.

Copy link

codecov bot commented Sep 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.17%. Comparing base (7ac05cd) to head (0a75116).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #4618    +/-   ##
========================================
  Coverage   97.16%   97.17%            
========================================
  Files        1160     1162     +2     
  Lines       40159    40267   +108     
========================================
+ Hits        39022    39130   +108     
  Misses       1137     1137            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@zachaysan zachaysan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great, just a few small questions / comments.

Comment on lines 13 to 14
segment_ids_to_create_overrides: list[int] = None,
segment_ids_to_delete_overrides: list[int] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand it's setting them equal to empty list below, but I still think the typing should match the default arguments.

Suggested change
segment_ids_to_create_overrides: list[int] = None,
segment_ids_to_delete_overrides: list[int] = None,
segment_ids_to_create_overrides: list[int] | None = None,
segment_ids_to_delete_overrides: list[int] | None = None,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's a fair point, updated.

Comment on lines 46 to 52
if _check(
segment_override_count + extra,
environment.project.max_segment_overrides_allowed,
):
return True

return False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if _check(
segment_override_count + extra,
environment.project.max_segment_overrides_allowed,
):
return True
return False
return _check(
segment_override_count + extra,
environment.project.max_segment_overrides_allowed,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, updated.

Comment on lines 1262 to 1263
# We create a new version, without making any changes, we shouldn't receive
# any errors.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused by this comment because a status.HTTP_400_BAD_REQUEST is returned below. Is a 400 response not considered an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this was a copy pasta error.

@matthewelwell matthewelwell added this pull request to the merge queue Sep 12, 2024
Merged via the queue into main with commit 52b9780 Sep 12, 2024
35 checks passed
@matthewelwell matthewelwell deleted the fix/versioning-segment-override-limits branch September 12, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants