feat: derive endpoint from auth.domain for WorkBuddy Global (workbuddy.ai) accounts - #2
Open
bimapopo345 wants to merge 1 commit into
Open
feat: derive endpoint from auth.domain for WorkBuddy Global (workbuddy.ai) accounts#2bimapopo345 wants to merge 1 commit into
bimapopo345 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 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 viaauth_meta. - Derives
endpointfromauth.domain(ashttps://{domain}) when no explicitauth.endpointis present. - Preserves existing fallback behavior to
DEFAULT_ENDPOINTwhen neitherendpointnordomainis 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 on lines
+377
to
+381
| domain = (auth_meta.get("domain") or "").strip() | ||
| if domain: | ||
| endpoint = ("https://" + domain.lstrip("./")).rstrip("/") | ||
| else: | ||
| endpoint = DEFAULT_ENDPOINT |
| 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("/") |
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
Global (workbuddy.ai) account exports carry
auth.domainbut noauth.endpointkey, somain()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.ai→https://www.workbuddy.ai) before falling back toDEFAULT_ENDPOINT, so a domain-bearing auth file routes to the correct realm without needing an explicitendpointfield.Why
{"auth":{"domain":"www.workbuddy.ai",...},"account":{...}}— exactly the shapeload_session()accepts, but the billing/growth endpoints live on the Global host.401with a misleading "re-login" hint.Testing
auth.domain = www.workbuddy.ai, noendpointkeypython signin.py status→HTTP 200, code 0fromhttps://www.workbuddy.ai/v2/billing/meter/checkin-activity-status✅auth.endpointor no domain still resolve exactly as beforePR-Codex overview
This PR refines how the
endpointis determined in thesignin.pyfile. It adds logic to derive theendpointfrom thedomainif it's available, improving the handling of global accounts that lack theendpointkey.Detailed summary
auth_metato hold the session'sauthdata.endpointassignment to check forendpointinauth_meta.endpointfromdomainif it exists.DEFAULT_ENDPOINTif nodomainorendpointis found.