Skip to content

fix: fix test in PR #5283#5381

Merged
rolodato merged 7 commits intofeat/if-modified-sincefrom
feat/if-modified-since-test-fix
Apr 24, 2025
Merged

fix: fix test in PR #5283#5381
rolodato merged 7 commits intofeat/if-modified-sincefrom
feat/if-modified-since-test-fix

Conversation

@matthewelwell
Copy link
Copy Markdown
Contributor

@matthewelwell matthewelwell commented Apr 24, 2025

This is a PR on top of #5283 to resolve the tests.

There were 2 issues which I've resolved in this PR:

  1. The updated_at value wasn't actually by updated by just renaming the environment, as explained here)
  2. If-Modified-Since is only accurate to the nearest second, so I've added a short sleep in the test to ensure that the test always passes. We could equally have artificially set the 'If-Modified-Since' to an earlier time, but I like that we're using the time from the previous request.

On top of this, I have also removed the AuthenticatedRequest class as it wasn't really being used correctly. Although we were annotating certain instances of the request instance with the class, it wasn't actually an instance of the AuthenticatedRequest class. If we want to modify the behaviour, I think this would be a wider change outside of the scope of this PR.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 24, 2025

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2025 2:10pm
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2025 2:10pm
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2025 2:10pm

@github-actions github-actions bot added api Issue related to the REST API fix labels Apr 24, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 24, 2025

Uffizzi Preview deployment-63099 was deleted.

@github-actions github-actions bot added fix and removed fix labels Apr 24, 2025
@matthewelwell matthewelwell marked this pull request as ready for review April 24, 2025 12:28
@matthewelwell matthewelwell requested a review from a team as a code owner April 24, 2025 12:28
@matthewelwell matthewelwell requested review from khvn26 and rolodato and removed request for a team and khvn26 April 24, 2025 12:28
@github-actions github-actions bot removed the fix label Apr 24, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 24, 2025

Docker builds report

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

@github-actions github-actions bot added the fix label Apr 24, 2025
@github-actions github-actions bot added fix and removed fix labels Apr 24, 2025
@github-actions github-actions bot added fix and removed fix labels Apr 24, 2025
@github-actions github-actions bot added fix and removed fix labels Apr 24, 2025
Comment on lines +168 to +170
environment_cache.delete_many(
[self.initial_value("api_key"), *[eak.key for eak in self.api_keys.all()]]
)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a temporary fix for now and I think we should perhaps asynchronise this. See further context in the conversation here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMO the correct fix would be to only ever use a single cache key for environments, and not have one cache key per server-side SDK key.

To achieve this, the endpoints that accept server-side SDK keys must also receive the client-side key, which is confusing with the current terminology. For example, something like GET /environment-document/abc123 -H "Authorization: ser..." instead of deriving the environment ID from the server-side key.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (feat/if-modified-since@aa011a1). Learn more about missing BASE report.

Additional details and impacted files
@@                    Coverage Diff                    @@
##             feat/if-modified-since    #5381   +/-   ##
=========================================================
  Coverage                          ?   97.62%           
=========================================================
  Files                             ?     1237           
  Lines                             ?    43006           
  Branches                          ?        0           
=========================================================
  Hits                              ?    41983           
  Misses                            ?     1023           
  Partials                          ?        0           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rolodato rolodato merged commit 5e97796 into feat/if-modified-since Apr 24, 2025
34 checks passed
@rolodato rolodato deleted the feat/if-modified-since-test-fix branch April 24, 2025 14:36
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