Skip to content

feat: derive endpoint from auth.domain for WorkBuddy Global (workbuddy.ai) accounts - #2

Open
bimapopo345 wants to merge 1 commit into
88lin:mainfrom
bimapopo345:feat/global-endpoint
Open

feat: derive endpoint from auth.domain for WorkBuddy Global (workbuddy.ai) accounts#2
bimapopo345 wants to merge 1 commit into
88lin:mainfrom
bimapopo345:feat/global-endpoint

Conversation

@bimapopo345

@bimapopo345 bimapopo345 commented Sep 7, 2026

Copy link
Copy Markdown

Summary

Global (workbuddy.ai) account exports carry auth.domain but no auth.endpoint key, so main() fell straight back to the CN default (https://copilot.tencent.com) and every request 401'd for a Global token.

This PR derives the endpoint from auth.domain (e.g. www.workbuddy.aihttps://www.workbuddy.ai) before falling back to DEFAULT_ENDPOINT, so a domain-bearing auth file routes to the correct realm without needing an explicit endpoint field.

Why

  • WorkBuddy Global login (e.g. via OAuth captured through CLI-style flows) stores {"auth":{"domain":"www.workbuddy.ai",...},"account":{...}} — exactly the shape load_session() accepts, but the billing/growth endpoints live on the Global host.
  • Current behavior silently routes Global tokens to the CN host → 401 with a misleading "re-login" hint.

Testing

  • Windows Server, Python 3.13
  • Auth file: global token with auth.domain = www.workbuddy.ai, no endpoint key
  • python signin.py statusHTTP 200, code 0 from https://www.workbuddy.ai/v2/billing/meter/checkin-activity-status
  • CN flow untouched: files with an explicit auth.endpoint or no domain still resolve exactly as before

PR-Codex overview

This PR refines how the endpoint is determined in the signin.py file. It adds logic to derive the endpoint from the domain if it's available, improving the handling of global accounts that lack the endpoint key.

Detailed summary

  • Introduced auth_meta to hold the session's auth data.
  • Modified endpoint assignment to check for endpoint in auth_meta.
  • Added logic to derive endpoint from domain if it exists.
  • Implemented a fallback to DEFAULT_ENDPOINT if no domain or endpoint is found.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copilot AI lite review requested due to automatic review settings September 7, 2026 03:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new domain-to-endpoint derivation needs stronger normalization/validation to avoid malformed URLs and unintended host selection when auth.domain contains a scheme, path, or userinfo.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes Global (workbuddy.ai) account routing by deriving the API base endpoint from auth.domain when auth.endpoint is missing, preventing Global tokens from incorrectly falling back to the CN default host.

Changes:

  • Refactors endpoint resolution to read session["auth"] once via auth_meta.
  • Derives endpoint from auth.domain (as https://{domain}) when no explicit auth.endpoint is present.
  • Preserves existing fallback behavior to DEFAULT_ENDPOINT when neither endpoint nor domain is available.
File summaries
File Description
signin.py Adds endpoint-derivation logic from auth.domain to support Global accounts that lack auth.endpoint.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread signin.py
Comment on lines +377 to +381
domain = (auth_meta.get("domain") or "").strip()
if domain:
endpoint = ("https://" + domain.lstrip("./")).rstrip("/")
else:
endpoint = DEFAULT_ENDPOINT
Comment thread signin.py
return 1
endpoint = ((session.get("auth") or {}).get("endpoint") or DEFAULT_ENDPOINT).rstrip("/")
auth_meta = session.get("auth") or {}
endpoint = (auth_meta.get("endpoint") or "").rstrip("/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants