[rust][selenium-manager]: do not ignore browser path when version is specified#17659
[rust][selenium-manager]: do not ignore browser path when version is specified#17659Delta456 wants to merge 11 commits into
Conversation
Code Review by Qodo
Context used✅ Tickets:
🎫 [Bug] SM ignores browser path when version is specified 🎫 2.48 doesn't trigger javascript in link's href on click() 🎫 Instance ChroneDriver Error: ConnectFailure✅ Compliance rules (platform):
14 rules 1. Mismatch error masked by cache
|
|
Code review by qodo was updated up to the latest commit 26efb88 |
f79f7c2 to
02638fb
Compare
|
Code review by qodo was updated up to the latest commit c179266 |
|
Code review by qodo was updated up to the latest commit 4f3546e |
|
Code review by qodo was updated up to the latest commit ac6d270 |
|
Code review by qodo was updated up to the latest commit c1dd3d1 |
|
I think @bonigarcia objection on Slack is correct here, and I was not. I have a use case in mind for the ignore, but it shouldn't need to be bundled into this bug fix. |
Should be fixed now |
|
Code review by qodo was updated up to the latest commit 5891a28 |
|
Code review by qodo was updated up to the latest commit 0a8c1d4 |
|
@Delta456 Have you tested this code locally? I just did it in Windows, and it works the same as before. In the following execution (run using your branch), @titusfortner: After thinking more about your original issue request (#17540), I'm pretty convinced this is not a bug. Simply, Selenium Manager gives priority to But independently of the name (call it a bug or a feature), I don't believe this new behavior (i.e., erroring on disagrees on those flags) is very relevant to users. Probably, the number of users affected by this change is close to zero. |
| if !original_browser_path.is_empty() { | ||
| return Err(anyhow!(format!( | ||
| "The browser at {} has version {} but {} {} was requested; \ | ||
| remove --browser-path to allow a browser download", | ||
| original_browser_path, | ||
| discovered_version, | ||
| self.get_browser_name(), | ||
| self.get_browser_version(), | ||
| ))); | ||
| } |
There was a problem hiding this comment.
1. Mismatch error masked by cache 🐞 Bug ≡ Correctness
The new major-version mismatch branch returns an error, but main.rs can still convert that error into an OK exit when cached-driver fallback is enabled, so the intended fail-fast behavior for conflicting --browser-path/--browser-version may not be enforced. This can allow automation to proceed despite a mismatch, depending on cache state.
Agent Prompt
### Issue description
The new major-version mismatch returns `Err(...)`, but Selenium Manager may still exit successfully (code 0) via the cached-driver fallback path in `main.rs`. This undermines the intended "fail fast" behavior for conflicting `--browser-path` + requested version.
### Issue Context
- The mismatch branch returns `Err` without disabling fallback.
- `main.rs` will `flush_and_exit(OK, ...)` when `is_fallback_driver_from_cache()` is true and a cached driver is found.
- `fallback_driver_from_cache` defaults to `true`, making this behavior likely on machines with any cached driver.
### Fix Focus Areas
- rust/src/lib.rs[584-593]
**Implementation direction:**
- Before returning the mismatch `Err`, call `self.set_fallback_driver_from_cache(false);` so `main.rs` won’t treat this user-input mismatch as recoverable.
- Consider applying the same change to the specific-version mismatch error path as well (even though it’s outside this focus hunk) to keep behavior consistent.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit c8f91a9 |
PR Summary by Qodo
Rust Selenium Manager: error on browser-path/version mismatch with ignore escape hatch
🐞 Bug fix🧪 Tests🕐 20-40 MinutesWalkthroughs
User Description
🔗 Related Issues
Fixes #17540
💥 What does this PR do?
SM silently discarded
--browser-pathand downloaded the requested version when versions didn't match. No error, no warning.This PR fixes that.
🔧 Implementation Notes
🤖 AI assistance
💡 Additional Considerations
🔄 Types of changes
AI Description
Diagram
graph TD A["selenium-manager CLI"] --> B["Parse args"] --> C["Discover browser version"] --> D{"browser-version == ignore?"} D -->|yes| E["Warn if browser-path set"] --> F["Use detected version"] D -->|no| G{"Specific version requested\nAND differs?"} G -->|yes, browser-path set| H["Error: mismatch + guidance"] G -->|yes, no browser-path| I["Download requested browser"] G -->|no| J["Proceed with detected version"]High-Level Assessment
The following are alternative approaches to this PR:
1. Add explicit flag (e.g., --ignore-browser-version-check)
2. Keep current behavior but emit warning and continue downloading
Recommendation: The PR’s approach is the safer default: treat --browser-path as authoritative and error on mismatches to prevent accidental browser swaps. If UX concerns arise, consider a dedicated --ignore-browser-version-check flag later; for now, the sentinel value
--browser-version ignoreprovides an explicit opt-out without expanding the flag surface.File Changes
Bug fix (1)
Tests (1)