Repository navigation
fix(cli): honor -c cache_mode instead of always bypassing the cache (#2365) - #2366
Merged
Merged
Conversation
…2365) --bypass-cache was a flag with default=True, so it always forced CacheMode.BYPASS after -c and config files were applied. Default it to False; CrawlerRunConfig already defaults to BYPASS, so plain crwl still skips the cache. -c and YAML/JSON configs also pass cache_mode as a string, which never matched the CacheMode enum, so CrawlerRunConfig now converts it.
CrawlerRunConfig now converts a string cache_mode to CacheMode and raises ValueError on an unknown one, which the Docker API turned into a 500. Check it in the untrusted gate so /crawl and /crawl/stream answer 400. The playground template test compared the raw "bypass" string with the loaded config; cache_mode is now a CacheMode, so compare enum values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2365.
crwlignored-c cache_mode=...and always bypassed the cache, for two reasons:--bypass-cachewas a flag withdefault=True, so it always setCacheMode.BYPASSafter-cand config files were applied.-cand YAML/JSON configs passcache_modeas a string ("enabled").CacheModeis a plainEnum, so the string never matched and the cache was never read or written.--bypass-cachenow defaults toFalse.CrawlerRunConfigalready defaults toBYPASS, so plaincrwlstill skips the cache.CrawlerRunConfignow converts a stringcache_modetoCacheMode, and an invalid value raises an error.List of files changed and why
crawl4ai/cli.py:--bypass-cachedefaults toFalseincrwlandcrwl crawl.crawl4ai/async_configs.py: convert a stringcache_modetoCacheMode.tests/cli/test_cli.py: default is stillBYPASS;-c cache_mode=enabledgivesENABLED;-bcstill forcesBYPASS.test_examples,test_missing_urlandtest_basic_crawlintests/cli/test_cli.pyalready fail ondevelop; this PR does not change them.