Fix captcha detection: login page is now a React SPA, HTML scraping never finds the field - #58
Open
vff wants to merge 1 commit into
Open
Fix captcha detection: login page is now a React SPA, HTML scraping never finds the field#58vff wants to merge 1 commit into
vff wants to merge 1 commit into
Conversation
…ever finds the field _check_captcha() used bs4 to scrape the login page HTML for an element with id=verificationCodeInput to decide whether a captcha was required. The login page is now rendered client-side (React SPA) and that element is never present in the static HTML response - so the check always returned False, raising 'Captcha required but captcha not found' even when the account genuinely needed one (fixes jgriss#53). _check_captcha() is only called by the with_solver decorator after a CaptchaRequiredException was already raised from _login(), i.e. after the login response JSON already confirmed verifyCodeCreate: true. So the HTML scraping step is unnecessary - go straight to fetching and solving the captcha image instead. Tested end-to-end against a live account on the uni003eu5 subdomain: login, captcha solve via the bundled ONNX model, and session-authenticated API calls (get_power_status, get_plant_ids) all succeed after this fix.
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.
Problem
_check_captcha()scrapes the static login page HTML looking for anelement with
id="verificationCodeInput"to decide whether a captchais required. The login page is now rendered client-side as a React SPA
(script bundles only, empty
<body>), so that element is never presentin the HTML response - the check always returns
False, and loginfails with
AuthenticationException("Login failed: Captcha required but captcha not found.")even when the account genuinely needs acaptcha. Matches #53.
Root cause
_check_captcha()is only ever called from thewith_solverdecoratorafter
_login()already raisedCaptchaRequiredException, which onlyhappens when the login response JSON contains
"verifyCodeCreate": true. In other words, by the time we reach_check_captcha(), wealready know a captcha is required from the API's own JSON response -
the HTML scraping step is redundant AND broken against the current
frontend.
Fix
Remove the HTML scraping check; go straight to fetching + solving the
captcha image, exactly as the old "captcha found" branch already did.
Testing
Verified end-to-end against a live account on the European (EU5)
server,
uni003eu5subdomain: login flow (pubkey → validateUser →captcha required → solve via bundled ONNX model → prevalidate →
re-login with verifycode) completes successfully, and subsequent
authenticated API calls (
get_power_status,get_plant_ids) workcorrectly. Confirmed the bug was present before this fix (same
account, same credentials).
I have not been able to test against other regions (e.g. China/APAC
servers) - if those use a different login frontend that still serves
the old server-rendered HTML with
verificationCodeInput, this changeshould be harmless there too, since the only thing removed is a check
that would have returned
Trueanyway on that markup. But flaggingthis in case a region-specific regression shows up.
Fixes #53