resolve payer: authenticate the lookup — without the token OC hides the email
ci/woodpecker/push/woodpecker Pipeline was canceled

Second live-only bug in the same helper. Sent unauthenticated, OC answers the
public view of an account: name comes back, email does not. A hand query with the
Personal-Token header returned conor.canaday@gmail.com for the very slug the
helper reported as email=None — so the fix would have resolved nobody, silently,
while looking like it worked.

The test now pins the header (the stub records what it was called with), because
the failure mode here is an absence, and an absence is exactly what a stub
forgets to check.
This commit is contained in:
inference-admin committed 2026-11-13 22:14:36 +00:00
1 parent 0458e8e5a5
commit 2cde368c1e
2 files changed
+18 -1

No files matched your search

+10 -1
View File
@@ -7418,7 +7418,16 @@ async def fetch_account_by_slug(slug: str) -> dict | None:
# around client.post), so the JSON is read here. Getting this wrong
# is invisible to a stubbed test and fatal in the container: the
# first live run raised 'Response object has no attribute get'.
resp = await _oc_graphql_post(client, {"query": query, "variables": {"slug": slug}})
resp = await _oc_graphql_post(
client,
{"query": query, "variables": {"slug": slug}},
# WITHOUT the personal token OC answers the unauthenticated view,
# which hides every email — the lookup then returns name='Conor W'
# and email=None while a hand query with the header returns
# conor.canaday@gmail.com. The header is the whole point.
headers={"Content-Type": "application/json",
"Personal-Token": OC_PERSONAL_TOKEN},
)
data = resp.json()
except Exception as e: # read failure: report, never raise
logger.warning("OC account lookup failed for slug %s: %s", slug, e)
+8
View File
@@ -60,9 +60,14 @@ class FakeResponse:
return self._payload
LAST_HEADERS = {}
def fake_post(payload):
"""Stand in for OC's GraphQL endpoint (the response wrapper, not the JSON)."""
async def _post(client, json_body, headers=None, attempts=2):
LAST_HEADERS.clear()
LAST_HEADERS.update(headers or {})
return FakeResponse(payload)
return _post
@@ -75,6 +80,9 @@ acct = asyncio.run(m.fetch_account_by_slug("guest-71e9d110"))
check(acct and acct["email"] == "conor.canaday@gmail.com",
f"the email is returned and normalised (got {acct and acct.get('email')!r})")
check(acct and acct["name"] == "Conor W", "the name comes back too, for the welcome email")
check(LAST_HEADERS.get("Personal-Token") == "test-token",
"the lookup AUTHENTICATES: without the personal token OC answers the unauthenticated view and hides every email "
f"(headers sent: {sorted(LAST_HEADERS)})")
print("2. an incognito profile yields NO email — and says so rather than guessing")
m._oc_graphql_post = fake_post({"data": {"account": {