fix(oura): tighten auth flow — detect email-not-found, replace sleeps with conditions#71
Open
maciejwitowski wants to merge 2 commits intomainfrom
Open
fix(oura): tighten auth flow — detect email-not-found, replace sleeps with conditions#71maciejwitowski wants to merge 2 commits intomainfrom
maciejwitowski wants to merge 2 commits intomainfrom
Conversation
When the user enters an email that is not associated with any Oura
account, Oura renders a "Your email not found" error page instead of
advancing to the send-code step. The connector previously proceeded to
click the send-code selector against the error page, then prompted the
user for an OTP that was never sent.
Detect the error text between email submit and the send-code click, and
throw a fatal auth_failed with a human-readable reason. The outer
try/catch will surface the reason via page.setData('error', ...) per
the honest telemetry contract, so the UI shows the real cause instead
of hanging on an OTP prompt.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… session probe
Trace analysis across 10+ successful runs showed ~22s of hardcoded
waitForTimeout per auth flow. This cuts most of it by replacing blind
sleeps with the condition each sleep was actually waiting for.
Changes to doLogin:
- Drop the DOM-based session detection retry loop (goto root + sleep 3s
+ DOM check + sleep 2s + DOM check). Probe /api/me directly on the
loaded dashboard origin. If the session is live we skip email/OTP
entirely.
- Remove the 3s sleep after safeGoto(/user/sign-in). The next step
already waitForSelector's the email input.
- Remove the 500ms sleeps between fill and click (email and OTP).
Playwright's fill already dispatches input/change events.
- Replace the 3s sleep + separate "email not found" probe with a single
race-based wait. Resolves as soon as either the next-step button
appears (happy path) or the error text shows (fail fast with
auth_failed).
- Remove the 3s sleep after clicking the send-code button. Replace with
waitForSelector on the OTP input.
- Replace the 5s sleep + goto root + double checkLoginStatus after OTP
submit with a waitForSelector on a dashboard-shaped element plus a
single fetchCloudApi('/api/me') verification.
Expected per-run auth time drops from ~40s to ~20s for first-time login
and from ~40s to ~3s for repeat logins with a valid cached session
(previously paid the full auth cost every time).
Condition-based waits are also more robust than sleeps: slow networks
no longer time out before the UI renders, fast networks no longer pay
unnecessary overhead.
Bumps version to 2.1.0. This is a feature-level change (behavior is
functionally equivalent on the happy path but meaningfully faster; the
cached-session optimization adds a new fast path), not a patch.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Schema Health Check — 6 issue(s) found41/47 scopes consistent | 0 missing schema files | 6 not in Gateway | 0 metadata drift | 0 orphaned View issuesNot registered in Gateway:
|
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
Oura connector reliability + performance pass, driven by manual trace analysis of ~10 successful runs and one failed run where the user was silently prompted for an OTP that would never arrive.
Two logical commits:
fix(oura): surface 'email not found' as auth_failed— before this, if a user entered an email Oura didn't recognize, the connector silently proceeded to the send-code click (against the error page), then prompted for an OTP that was never sent. Now we detect Oura's "Your email not found" copy between email submit and send-code, throw a fatalauth_failedwith a human-readable reason, and surface it to the UI via the existingpage.setData('error', ...)plumbing per the honest-telemetry contract.perf(oura): replace sleep-based auth waits with conditions; API-first session probe— trace analysis showed ~22s of hardcodedwaitForTimeoutper auth flow. Replaced blind sleeps with condition-based waits. New behavior:/api/meright after the initial goto. If the cached session is still live, skip email/OTP entirely — repeat logins go from ~40s to ~3s./user/sign-ingoto (next step already waits on the email input).waitForSelectoron the OTP input.checkLoginStatusafter OTP submit withwaitForSelectoron a dashboard element +fetchCloudApi('/api/me')verification.Expected impact on reliability numbers
Version bump
Bumped
versionin bothoura-playwright.jsonand theVERSIONconstant:2.0.0→2.1.0. Feature-level bump because the cached-session fast path is new behavior. Publish a fresh2.1.0artifact rather than republishing over2.0.0— context-gateway'smanifest.lock.jsonis keyed on version, and overwriting a published version silently breaks anyone with a cached resolve (see theinstagram-api-playwright@2.0.3drift that happened earlier this week).Test plan
node --checkpasses on the updated script.2.0.0available for comparison.Out of scope (flagged for later)
button[name="selectedId"], button#submit-buttoncompound selector. It's fragile (Auth0 identity picker can match first on some flows), but it works on current staging. Separate reliability investigation./api/meprobe by skipping the goto entirely, but requires runner changes outside this repo.🤖 Generated with Claude Code