-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Hi,
I have a function in a router that receives a request and sends a request to another service.
@router.route("/users/{username}/bookings")
def user_booking(uri: ParseResult, request: Request, params):
global users
if users == None:
open_file()
username = params['username']
if username not in users:
raise Exception("Not found")
resp = send(Request("GET", f"/bookings/{username}", {}, None))
print(f"Response: {resp}")
return Response(200, {}, resp.body)I get the following error:

It seems like set_authority is throwing an error. On looking at the source code of that function, it has not been implemented.
def set_authority(self, authority: Optional[str]) -> None:
"""
Set the HTTP Authority for the Request. A value of `none` may be used
with Related Schemes which do not require an Authority. The HTTP and
HTTPS schemes always require an authority. Fails if the string given is
not a syntactically valid uri authority.
Raises: `spin_sdk.wit.types.Err(None)`
"""
raise NotImplementedErrorAnother thing is the error says line 883 and this is not at line 883.
at line 883, the function is:
def set_between_bytes_timeout(self, duration: Optional[int]) -> None:
"""
Set the timeout for receiving subsequent chunks of bytes in the Response
body stream. An error return value indicates that this timeout is not
supported.
Raises: `spin_sdk.wit.types.Err(None)`
"""
raise NotImplementedErrorOn adding a few logs into spin-python-sdk, I see the following differences between this example and my code:
Example:
request Request(method='GET', uri='https://example.com', headers={}, body=None)
Parsed Url: ParseResult(scheme='https', netloc='example.com', path='', params='', query='', fragment='')
Output of my component:
request Request(method='GET', uri='/bookings/dwight_schrute', headers={}, body=None)
Parsed Url: ParseResult(scheme='', netloc='', path='/bookings/dwight_schrute', params='', query='', fragment='')
I see that both the scheme and netloc fields are empty.
On changing the outbound hosts to:
allowed_outbound_hosts = ["http://*:*", "https://*:*"]
from:
allowed_outbound_hosts = ["http://self", "https://self"]
and changing the url to point to http://127.0.0.1:3000/users/{username}/bookings (the default url that spin exposes the application to), it seems to be working.
On changing the url to http://self/users/{username}/bookings it throws a DNS not found error, as https://self is not a website that exists.