FNNDSC / pman

A process management system written in python
MIT License
23 stars 33 forks source link

Error handling if invalid meta JSON file passed #8

Closed NicolasRannou closed 3 years ago

NicolasRannou commented 7 years ago

Running the following command makes purl hang and display error in pman server:

Notice the not JSON-valid double quote after "cmd": "cmd”.

purl --verb POST --raw --http 172.17.0.2:5010/api/v1/cmd --jsonwrapper 'payload' --msg \
'{  "action": "run",
        "meta": {
                "cmd”:      "ls",
                "auid":     "rudolphpienaar",
                "jid":      "cal-job-1234",
                "threaded": true
        }
}' --quiet --jsonpprintindent 4
  1. terminal running purl hangs
  2. error message on pman
    
    2017-03-16 11:55:54.042755 |      <Listener(Thread-5, started 139819640420096)> |                        process | ***********************************************
    2017-03-16 11:55:54.043535 |      <Listener(Thread-5, started 139819640420096)> |                        process | Request = ...
    2017-03-16 11:55:54.044897 |      <Listener(Thread-5, started 139819640420096)> |                        process | ['POST /api/v1/cmd HTTP/1.1\r', 'Host: 172.17.0.2:5010\r', 'User-Agent: PycURL/7.43.0 libcurl/7.47.0 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3\r', 'Accept: */*\r', 'Content-Length: 15\r', 'Content-Type: application/x-www-form-urlencoded\r', '\r', '{"payload": {}}']
    2017-03-16 11:55:54.045879 |      <Listener(Thread-5, started 139819640420096)> |                        process | json_payload = {"payload": {}}
    Exception in thread Thread-5:
    Traceback (most recent call last):
    File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
    File "/usr/local/lib/python3.5/dist-packages/pman/pman.py", line 549, in run
    resultFromProcessing    = self.process(request)
    File "/usr/local/lib/python3.5/dist-packages/pman/pman.py", line 1225, in process
    payload_verb        = d_request['action']
    KeyError: 'action'
    2017-03-16 11:55:54.038912 |      <Listener(Thread-4, started 139819989149440)> |                            run | Received b'' from client_id: b'\x00k\x8bEg'

2017-03-16 11:55:54.048111 | <Listener(Thread-4, started 139819989149440)> | run | Listener ID - 0: run() - Received comms from client.