Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception/crash when connecting to an agent through browser #153

Closed
Archento opened this issue Sep 13, 2023 · 0 comments · Fixed by #166
Closed

Exception/crash when connecting to an agent through browser #153

Archento opened this issue Sep 13, 2023 · 0 comments · Fixed by #166
Labels
c-bug Category: Something isn't working

Comments

@Archento
Copy link
Member

Problem:

It still sometimes happens that the endpoint of an agent (incl. /submit) is being opened in a browser which leads to the following observation and leaves the agent in a stale state (stops working)

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/uagents/asgi.py", line 81, in __call__
    if b"application/json" not in headers[b"content-type"]:
KeyError: b'content-type'

We check in:

if scope["path"] != "/submit":
if the path is ending with /submit which is true most of the time if you know how to interact with an agent OR if you do some internal routing.
The internal routing is often the case when hosting an agent in the cloud or making it accessible through a web2 DNS service.

-> The browser by default may not add the content type property to the request, leading to a key error in:

if b"application/json" not in headers[b"content-type"]:

Proposal

This should be an easy fix to prevent the agent from crashing but I would like to start the discussion here if we would additionally give a standard feedback/response to the browser client that the agent is up and running, e.g. GET "/submit" -> 200, OK - Agent is running

@Archento Archento added the c-bug Category: Something isn't working label Sep 13, 2023
@jrriehl jrriehl linked a pull request Sep 19, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-bug Category: Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant