Repository navigation
fix(db-engine): make cachetools import optional in aws_iam - #38269
Conversation
google-auth 2.48.0 dropped cachetools from its dependencies, breaking the transitive chain that previously guaranteed its availability. Wrap the import in try/except with a plain dict fallback so the module loads even when cachetools is not installed. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Code Review Agent Run #8bf641Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #38269 +/- ##
==========================================
- Coverage 80.13% 79.05% -1.08%
==========================================
Files 2922 2875 -47
Lines 172088 173796 +1708
Branches 39941 38629 -1312
==========================================
- Hits 137904 137403 -501
- Misses 31607 33657 +2050
- Partials 2577 2736 +159
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Vitor-Avila
left a comment
There was a problem hiding this comment.
Left a non-blocking comment. I'm fine with the way it is, just thinking that we could also just raise and force the user to install the missing dep.
|
thanks for working on this btw! I faced an error for missing this dependency last week and wasn't sure why -- now I know! 🙌 |
|
@dpgaspar checking in... want help with getting this across the finish line? I'll update the branch now for good measure. |
A plain dict never evicts, so once an STS credential's real 600s TTL elapsed, every call after that would keep reusing the same expired credentials until the process restarted -- the opposite of "the feature still works" this fallback was meant to provide. Replace it with a MutableMapping that always misses, so get_iam_credentials falls through to a fresh assume_role call every time cachetools isn't installed. Also satisfies the open review threads: a no-op cache closes the TTL-less staleness bug CodeAnt flagged twice without reintroducing the ImportError this PR exists to avoid (the alternative raised on the Vitor-Avila thread), and gives the fallback assignment its own type annotation per CodeAnt's minor note. Co-Authored-By: Evan Rusackas <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Pushed baa4099 to fix the failing pre-commit (ruff-format) and address the open review threads:
CI should be green shortly; will keep an eye on it. |
|
@Vitor-Avila @dpgaspar check my work, and merge if you dig it :D |
There was a problem hiding this comment.
Code Review Agent Run #979562
Actionable Suggestions - 1
-
superset/db_engine_specs/aws_iam.py - 1
- Dead fallback code · Line 86-91
Review Details
-
Files reviewed - 2 · Commit Range:
ea800f4..baa4099- superset/db_engine_specs/aws_iam.py
- tests/unit_tests/db_engine_specs/test_aws_iam.py
-
Files skipped - 0
-
Tools
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers an incremental AI Review. -
/review full- Manually triggers a full AI Review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
| try: | ||
| from cachetools import TTLCache | ||
|
|
||
| _credentials_cache = TTLCache(maxsize=100, ttl=600) | ||
| except ImportError: | ||
| _credentials_cache = _NoCache() |
There was a problem hiding this comment.
cachetools is a hard dependency (pyproject.toml:45, requirements/base.txt:47, requirements/development.txt:115), so the except ImportError branch and the whole _NoCache class are unreachable in any supported install. This is ~40 lines of dead code that also misleads readers into thinking cachetools is optional. Either drop the fallback or document the environment that can lack cachetools.
Code Review Run #979562
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
|
@Vitor-Avila checking back in. Your approval predates my push in baa4099, which swapped the plain-dict fallback for a no-op cache instead of raising (so there's no stale-credential risk and no ImportError). CI is green and the branch is clean against master. Mind taking a quick look at the new approach? If it works for you, I think this is good to merge. |
Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Evan Rusackas <[email protected]> Co-authored-by: Evan Rusackas <[email protected]> (cherry picked from commit 488810d)
SUMMARY
google-auth2.48.0 droppedcachetoolsfrom its dependencies, breaking the transitive dependency chain (shillelagh→google-auth→cachetools) that previously guaranteed its availability. Whilerequirements/base.txtstill pinscachetools==6.2.1, a freshpip install apache-supersetfrompyproject.tomlcan resolvegoogle-auth>=2.48.0and fail with anImportErrorwhen loadingsuperset.db_engine_specs.aws_iam.This PR wraps the
cachetoolsimport in atry/exceptwith a plaindictfallback, consistent with howboto3is already lazily imported in the same file. Whencachetoolsis available,TTLCacheis used as before; when it isn't, the cache degrades to a plain dict (no TTL expiry, but the feature still works).BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — no UI changes.
TESTING INSTRUCTIONS
cachetoolsfrom your environmentImportErrorfromaws_iam.pycachetoolsand verify the TTLCache-based credential caching still worksADDITIONAL INFORMATION