Skip to content

credits: labs-gated on migrated accounts, and the error blames SAPISID for a host it never contacted #795

Closed

Description

@ffroliva

Split out of #791 so fixing the login oracle does not leave a green auth status next to a red credits.

Two defects, one code path

api/credits.py:51 probes the labs NextAuth session unconditionally:

session_status, session_body, _ = await fetch_flow_session_httpx(profile_dir)

then extracts access_token (:64-66) before calling routes.CREDITS with hardcoded origin/referer of https://labs.google (:80-81).

1. It stays broken on migrated accounts even after login is fixed

For an account Google has moved to flow.google.com, labs returns 200 {} with no access_token, so the run dies at credits.py:67-72 regardless of how the profile authenticated. If #791's oracle lands without this, the product reports "Flow session verified" and then fails gflow credits on the same profile — an inconsistent state that will read as a regression.

2. The error blames something that is not the cause and a host that was never contacted

The raise is AisandboxAuthError(detail="no access_token in Flow session", route="auth/session"), but the rendered title is "aisandbox-pa authentication failed" (errors.py:196) and the remediation says "SAPISID cookie missing, expired, or unreadable" (errors.py:198).

At that point aisandbox-pa has not been contacted at all, and SAPISID is present and fine — it is what made the outcome GOOGLE_SESSION_ONLY rather than NO_SESSION in the first place. A user following that remediation re-authenticates, which cannot help.

Reported downstream in #791: "gflow credits list → aisandbox-pa authentication failed".

Suggested shape

  • Distinguish "the labs session BFF returned no token" from "aisandbox-pa rejected us" — they are different failures with different remediations, and only one of them is about SAPISID.
  • Decide what credits means for a migrated account before wiring a new probe: the Veo balance surface for that cohort has not been located yet, so the honest interim may be a typed "not available on this host" rather than an auth error.

Surfaces

gflow credits user / gflow credits list, and the MCP twin if one exists — check the six mirror axes.

Refs #791

Activity

  1. ffroliva commented on Sep 12, 2026

    @ffroliva
    OwnerAuthor

    Half fixed on develop in #797 (4d4ea3df).

    Landed — defect 2 (the misleading error). The no access_token raise now carries an accurate remediation_hint instead of inheriting "SAPISID cookie missing, expired, or unreadable". It names the real cause: labs.google's session carries no API token for this account, which is expected on accounts migrated to flow.google.com, and re-authenticating will not help. That re-login loop could never terminate on that cohort.

    Still open — defect 1 (credits is labs-only on migrated accounts). api/credits.py:51 still probes the labs session unconditionally, so gflow credits remains unavailable on the migrated host. That half needs a wire discovery: the Veo balance surface for the migrated cohort has not been located yet, and inventing a probe without measuring one would be a guess.

    Worth stating the ordering explicitly: this must not be forgotten when #791's login oracle lands. The moment a migrated account can authenticate, auth status goes green while credits stays red on the same profile — an inconsistent state that will read as a regression introduced by the login fix. Either the balance surface gets found first, or credits should return a typed "not available on this host" for migrated accounts rather than an auth error.

  2. ffroliva commented on Sep 17, 2026

    @ffroliva
    OwnerAuthor

    Related: #864 fixes the same pattern (a labs call failing on a flow.google.com account and advising a re-login) for createProject, following the #797 approach used here.

  3. added 2 commits that reference this issue on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions