mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-11 12:27:13 +00:00
fix(copilot): guard request_flags against a non-dict last message (#5274)
request_flags derives (agent, vision) and does last.get("role") after only
a truthy check. A client can send a bare-string message element
("messages": ["hi"]), and the vision loop right below already guards each
element with isinstance — so the .get() on a non-dict last element is an
oversight that raises AttributeError on every Copilot-proxied request with
such a body.
Use isinstance(last, dict) to match the loop's own guard.
Fixes #5273
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -89,6 +89,18 @@ def test_request_flags_vision():
|
||||
assert vision is True
|
||||
|
||||
|
||||
def test_request_flags_non_dict_last_message_does_not_crash():
|
||||
# A client can send a bare-string (non-dict) last element; before the
|
||||
# isinstance guard this raised AttributeError on last.get("role").
|
||||
assert copilot.request_flags(["hi"]) == (False, False)
|
||||
assert copilot.request_flags([{"role": "user"}, "trailing"]) == (False, False)
|
||||
|
||||
|
||||
def test_request_flags_empty_and_none():
|
||||
assert copilot.request_flags([]) == (False, False)
|
||||
assert copilot.request_flags(None) == (False, False)
|
||||
|
||||
|
||||
def test_apply_request_headers_mutates():
|
||||
h = {"X-GitHub-Api-Version": "v"}
|
||||
copilot.apply_request_headers(h, [{"role": "tool", "content": "x"}])
|
||||
|
||||
Reference in New Issue
Block a user