binary-husky/gpt_academic · error · NotAllowedToAccess
self.struct["result"]["message"]
Error message
self.struct["result"]["message"]
What it means
Not an error message but the KeyError source expression: when the parsed conversation-create JSON has result.value == 'UnauthorizedRequest', the code raises NotAllowedToAccess(self.struct['result']['message']). If the result object lacks the 'message' key, Python raises KeyError('message') whose repr is shown — the unauthorized response had no message field.
Source
Thrown at request_llms/edge_gpt_free.py:349
or "https://edgeservices.bing.com/edgesvc/turing/conversation/create",
)
if response.status_code != 200:
response = self.session.get(
"https://edge.churchless.tech/edgesvc/turing/conversation/create",
)
if response.status_code != 200:
print(f"Status code: {response.status_code}")
print(response.text)
print(response.url)
raise Exception("Authentication failed")
try:
self.struct = response.json()
except (json.decoder.JSONDecodeError, NotAllowedToAccess) as exc:
raise Exception(
"Authentication failed. You have not been accepted into the beta.",
) from exc
if self.struct["result"]["value"] == "UnauthorizedRequest":
raise NotAllowedToAccess(self.struct["result"]["message"])
@staticmethod
async def create(
proxy=None,
cookies=None,
):
self = _Conversation(async_mode=True)
self.struct = {
"conversationId": None,
"clientId": None,
"conversationSignature": None,
"result": {"value": "Success", "message": None},
}
self.proxy = proxy
proxy = (
proxy
or os.environ.get("all_proxy")
or os.environ.get("ALL_PROXY")View on GitHub (pinned to d6bde0fa54)
Solutions
- Refresh the Bing cookies — most UnauthorizedRequest errors come from stale credentials
- Use .get() so a missing message degrades gracefully and the real status value is still logged
- Compare the raw JSON from conversation/create (print response.text) with the expected schema to detect proxy/API changes
- Retry with a valid BING_PROXY_URL or default endpoint
Example fix
# before
if self.struct["result"]["value"] == "UnauthorizedRequest":
raise NotAllowedToAccess(self.struct["result"]["message"])
# after
if self.struct["result"]["value"] == "UnauthorizedRequest":
raise NotAllowedToAccess(self.struct["result"].get("message") or "UnauthorizedRequest") Defensive patterns
Strategy: type-guard
Validate before calling
result = struct.get('result', {})
if result.get('value') == 'UnauthorizedRequest':
raise NotAllowedToAccess(result.get('message') or 'UnauthorizedRequest (no message)') Type guard
def has_result_message(struct) -> bool:
result = struct.get('result') or {}
return isinstance(result.get('message'), str) Try / catch
try:
...
except KeyError as e:
if e.args and e.args[0] == 'message':
logger.error('Bing returned UnauthorizedRequest without message; refresh cookies')
raise NotAllowedToAccess('UnauthorizedRequest (no message)') from e
raise Prevention
- Use .get() on all third-party JSON envelopes
- Log the raw struct once when the schema surprises you
- Refresh cookies on any UnauthorizedRequest-shaped failure
When it happens
Trigger: request_llms/edge_gpt_free.py:349: Bing returns JSON with result.value 'UnauthorizedRequest' but without result.message — invalid/expired conversation signature or cookies; or the struct shape from the proxy differs from the expected schema. The KeyError fires only in the no-message case; otherwise NotAllowedToAccess carries Bing's own message.
Common situations: Expired _U cookie producing a minimal error payload; churchless fallback proxy returning a trimmed error body; Bing API change altering the result envelope; async create() initializing a synthetic struct where message is None (that path does not raise, but desynced overrides can).
Related errors
- Authentication failed
- Authentication failed. You have not been accepted into the b
- Doc2x return an error: Trace ID: {trace_id} {uid} {response.
- 你提供了错误的API_KEY。 1. 临时解决方案:直接在输入区键入api_key,然后回车提交。 2. 长效解决方
- 你提供了错误的API_KEY。 1. 临时解决方案:直接在输入区键入api_key,然后回车提交。 2. 长效解决方
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/f38276f312231770.
Report an issue: GitHub.