Thanks to visit codestin.com
Credit goes to github.com

Skip to content

correctly calculate cache key for sub dependencies#3684

Closed
ojii wants to merge 2 commits into
fastapi:masterfrom
ojii:issue-469
Closed

correctly calculate cache key for sub dependencies#3684
ojii wants to merge 2 commits into
fastapi:masterfrom
ojii:issue-469

Conversation

@ojii

@ojii ojii commented Aug 11, 2021

Copy link
Copy Markdown

This fixes #469 (at least partially).

When sub dependencies are derived, the cache key would be calculated incorrectly if the sub dependency is a Security dependency with scopes. This change ensures the cache_key is re-calculated whenever its constituent parts are modified.

This solves the problem of SecurityScopes not having the correct value, but now the dependency passed to Security can be invoked multiple times (in the provided test it is invoked twice).

When sub dependencies are derived, the cache key would be calculated
incorrectly if the sub dependency is a Security dependency with scopes.
@ojii

ojii commented Dec 2, 2021

Copy link
Copy Markdown
Author

@tiangolo is there anything I can do to have this looked at?

@dimaqq

dimaqq commented Feb 14, 2022

Copy link
Copy Markdown
Contributor

Inquisitive minds want to know...

@codecov

codecov Bot commented Sep 2, 2022

Copy link
Copy Markdown

Codecov Report

Merging #3684 (6db35c0) into master (fbe1a80) will decrease coverage by 11.35%.
The diff coverage is 92.59%.

@@             Coverage Diff              @@
##            master    #3684       +/-   ##
============================================
- Coverage   100.00%   88.64%   -11.36%     
============================================
  Files          538      503       -35     
  Lines        13872    12957      -915     
============================================
- Hits         13872    11486     -2386     
- Misses           0     1471     +1471     
Impacted Files Coverage Δ
fastapi/dependencies/models.py 94.73% <83.33%> (-5.27%) ⬇️
tests/test_dependency_security_scopes.py 100.00% <100.00%> (ø)
docs_src/app_testing/app_b_py310/main.py 0.00% <0.00%> (-100.00%) ⬇️
docs_src/sql_databases/sql_app_py39/crud.py 0.00% <0.00%> (-100.00%) ⬇️
docs_src/sql_databases/sql_app_py39/main.py 0.00% <0.00%> (-100.00%) ⬇️
docs_src/sql_databases/sql_app_py310/crud.py 0.00% <0.00%> (-100.00%) ⬇️
docs_src/sql_databases/sql_app_py310/main.py 0.00% <0.00%> (-100.00%) ⬇️
docs_src/app_testing/app_b_py310/test_main.py 0.00% <0.00%> (-100.00%) ⬇️
docs_src/sql_databases/sql_app_py39/models.py 0.00% <0.00%> (-100.00%) ⬇️
docs_src/sql_databases_peewee/sql_app/crud.py 0.00% <0.00%> (-100.00%) ⬇️
... and 233 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions

github-actions Bot commented Sep 2, 2022

Copy link
Copy Markdown
Contributor

📝 Docs preview for commit 6db35c0 at: https://631214f7ef40931be7f74c4f--fastapi.netlify.app

@tiangolo

tiangolo commented Sep 2, 2022

Copy link
Copy Markdown
Member

Thanks for the interest and work @ojii! I'm trying this and I see that the test passes even without the changes. I'm also trying several examples locally copying things from that issue, but it seems to work, or I'm not understanding the problem correctly.

But I have the feeling that this was solved in #2945

Could you check that one? That fix is available in FastAPI 0.80.0

@ojii

ojii commented Sep 5, 2022

Copy link
Copy Markdown
Author

@tiangolo that fix looks okay to me.

@ojii ojii closed this Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Router level Security dependency blocks route level dependency

3 participants