-
-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Here's some example code to replicate the issue.
from __future__ import annotations
import tinychain as tc
URI = tc.URI("http://127.0.0.1:8702/demo")
class User(tc.app.Model):
__uri__ = URI.append("user")
username = tc.Column("username", tc.String, 100)
def __init__(self, username):
self.username = username
class UserService(tc.graph.Graph):
__uri__ = URI
@tc.post
def create_user(self, new_user: User) -> tc.Number:
user_id = self.user.max_id() + 1
return tc.After(
self.user.insert([user_id], [new_user.username]),
user_id
)
def start_host(name, apps):
from tests.tctest.process import start_local_host, start_docker
# return start_local_host(name, apps)
return start_docker(name, apps)
if __name__ == "__main__":
host = start_host("demo", [UserService(models=[User])])
host.post("/demo/create_user", {"username": "user"})
When running the above we get the following error:
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/cormac/workspace/python/tinychain/script.py", line 43, in <module>
assert host.post("/demo/create_user", {"username": "user"}) == 10
File "/home/cormac/workspace/python/tinychain/client/tinychain/host.py", line 113, in post
return self._handle(request)
File "/home/cormac/workspace/python/tinychain/client/tinychain/host.py", line 48, in _handle
raise BadRequest(response)
tinychain.error.BadRequest: {'/error/bad_request': {'message': 'cannot cast into type String from: (username, /state/scalar/value/string, 100)', 'stack': ['while resolving _return_when', 'in call to POST class http://127.0.0.1:8702/demo instance /create_user']}}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working