This repository was archived by the owner on May 10, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on May 10, 2023. It is now read-only.
Invalid api.idl file should provide better error info #1
Copy link
Copy link
Closed
Description
Currently, an invalid api.idl file displays a misleading/unhelpful error about a missing file.
tl;dr - says '[ERROR] 2' and '[ERROR] No such file or directory' when it should really say something like failed to parse api.idl or even better, invalid api.idl - function 'add' is missing a return type
Repro:
Create a new project
(venv)➜ stackhut mkdir demo
(venv)➜ stackhut cd demo
(venv)➜ demo ls
(venv)➜ demo stackhut init fedora python
19:27:48 [INFO ] Starting StackHut Toolkit
19:27:48 [INFO ] Creating service USERNAME/demo
Change api.idl by removing the return value from the add function.
(venv)➜ demo git:(master) ✗ diff api.idl api-original.idl
3c3
< add(x int, y int)
---
> add(x int, y int) int
Try to run locally:
(venv)➜ demo git:(master) ✗ stackhut runhost
19:28:02 [INFO ] Starting StackHut Toolkit
19:28:02 [INFO ] Started StackHut Request Server - press Ctrl-C to quit
19:28:02 [ERROR] 2
19:28:02 [ERROR] No such file or directory
19:28:02 [INFO ] Please send us an email at toolkit@stackhut.com or open an issue at http://www.github.com/StackHut/stackhut-toolkit - thanks!
19:28:02 [INFO ] Exiting (run in verbose mode for more information)
Running with the -v flag reveals the true problem, which is actually two-fold (looks like it is failing to report the issue and THAT is the file not found content?)
(venv)➜ demo git:(master) ✗ stackhut -v runhost
19:35:47 [INFO ] Starting StackHut Toolkit
19:35:47 [DEBUG] User analytics enabled
19:35:47 [DEBUG] Starting service USERNAME/demo:latest
19:35:47 [INFO ] Started StackHut Request Server - press Ctrl-C to quit
19:35:47 [DEBUG] Starting Service Runner
19:35:47 [ERROR] 2
19:35:47 [ERROR] No such file or directory
19:35:47 [INFO ] Please send us an email at toolkit@stackhut.com or open an issue at http://www.github.com/StackHut/stackhut-toolkit - thanks!
19:35:47 [DEBUG] Sending analytics msg to cli_exception
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/stackhut_toolkit/commands.py", line 367, in run
with ServiceRunner(backend, self.hutcfg) as runner:
File "/usr/local/lib/python3.4/site-packages/stackhut_common/runtime/runner.py", line 45, in __init__
self.rpc = rpc.StackHutRPC(self.backend, self.shim_cmd)
File "/usr/local/lib/python3.4/site-packages/stackhut_common/runtime/rpc.py", line 105, in __init__
self.contract = contract_from_file(CONTRACTFILE)
File "/usr/local/lib/python3.4/site-packages/stackhut_common/barrister/runtime.py", line 39, in contract_from_file
return Contract(json.loads(j))
File "/usr/local/lib/python3.4/site-packages/stackhut_common/barrister/runtime.py", line 803, in __init__
self.interfaces[e["name"]] = Interface(e, self)
File "/usr/local/lib/python3.4/site-packages/stackhut_common/barrister/runtime.py", line 959, in __init__
self.functions[f["name"]] = Function(self.name, f, contract)
File "/usr/local/lib/python3.4/site-packages/stackhut_common/barrister/runtime.py", line 1126, in __init__
self.returns = Type(f["returns"])
KeyError: 'returns'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/stackhut", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.4/site-packages/stackhut_toolkit/__main__.py", line 52, in main
retval = runner.start()
File "/usr/local/lib/python3.4/site-packages/stackhut_common/commands.py", line 85, in start
raise e
File "/usr/local/lib/python3.4/site-packages/stackhut_common/commands.py", line 71, in start
retval = subfunc.run()
File "/usr/local/lib/python3.4/site-packages/stackhut_toolkit/commands.py", line 372, in run
os.remove(rpc.REQ_FIFO)
FileNotFoundError: [Errno 2] No such file or directory: '.req.json'
Metadata
Metadata
Assignees
Labels
No labels
Activity
mands commentedon Sep 23, 2015
Shoot - thanks for digging into this. I must admit to getting the "ERROR 2" message myself on several occasions but didn't put 2 and 2 together (pardon the pun! :))
Will look into it this evening and try merge the fixes - thanks!
mands commentedon Sep 23, 2015
Merged - thanks :)