Fix builtin browser failing to start with 'NoneType' object has no attribute 'browser_type' - #2104
Open
Liang-HZ wants to merge 1 commit into
Open
Conversation
ManagedBrowser.__init__ still declares and documents the legacy keyword
arguments, but its body reads every value from browser_config, which
defaults to None. launch_builtin_browser() is the one caller that still
passes only the legacy kwargs, so 'crwl browser start' and
BrowserProfiler.launch_builtin_browser() always raise:
'NoneType' object has no attribute 'browser_type'
The two sibling call sites in browser_profiler.py were already migrated
to browser_config= (the old kwargs remain commented out next to them),
so this one appears to have been missed.
- launch_builtin_browser() now builds a BrowserConfig and passes it.
- ManagedBrowser.__init__ falls back to the documented legacy keyword
arguments when browser_config is None, instead of raising an opaque
AttributeError.
Refs unclecode#1139, unclecode#1142
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
crwl browser startandBrowserProfiler.launch_builtin_browser()fail unconditionally with:ManagedBrowser.__init__still declares — and documents — the legacy keywordarguments (
browser_type,user_data_dir,headless,host,debugging_port,cdp_url), but its body reads every value frombrowser_config, which defaultsto
None:launch_builtin_browser()is the one caller that still passes only the legacykwargs, so it raises every time. The two other call sites in the same file were
already migrated to
browser_config=(the old kwargs are still sitting therecommented out), which suggests this one was simply missed during the refactor.
Fix
Two small changes:
browser_profiler.py—launch_builtin_browser()now builds aBrowserConfigand passes it, matching the two sibling call sites in the same file.
browser_manager.py—ManagedBrowser.__init__falls back to the documentedlegacy keyword arguments when
browser_config is None, instead of raising anopaque
AttributeError. This keeps the published signature honest and protectsany third-party code still calling it the old way.
Reproduction
Before:
After:
crwl browser status/crwl browser stopandBrowserConfig(browser_mode="builtin")work against the started instance afterwards.
Also verified that constructing
ManagedBrowser(...)with only the legacy kwargsno longer raises, and that passing
browser_config=behaves exactly as before.Related issues
against 0.6.3 via
crwl browser start. Closed, but the failure still reproduceson
main.Verified against
mainat the time of writing: both the missingbrowser_configin
launch_builtin_browser()and the unconditionalbrowser_config.*reads inManagedBrowser.__init__are still present.