zerovm / zerocloud

Swift middleware for Zerocloud
Apache License 2.0
53 stars 14 forks source link

REST API errors on GET with no request contents #152

Closed larsbutler closed 10 years ago

larsbutler commented 10 years ago

I found this issue while build a zapp which handles REST API requests. Here's the system.map:

[{
    "name": "example",
    "exec": {
        "path": "file://python2.7:python",
        "args": "main.py"
    },
    "devices": [
        {"name": "python2.7"},
        {"name": "stdin"},
        {"name": "stdout", "content_type": "message/http"},
        {"name": "input", "path": "swift://~/example-store"}
    ]
}]

It's an application to/from which you can POST/GET files. POSTing files works, and the stdin device is required for this. The following curl command works:

$ curl -i -X POST -H "X-Zerovm-Execute: api/1.0" -H "X-Auth-Token: $OS_AUTH_TOKEN" $OS_STORAGE_URL/example --data-binary @test.py

If I try to send a GET request (which naturally has no request content), if fails because ZeroCloud expects there to be something on stdin:

$ curl -i -X GET -H "X-Zerovm-Execute: api/1.0" -H "X-Auth-Token: $OS_AUTH_TOKEN" $OS_STORAGE_URL/example
HTTP/1.1 400 Bad Request
X-Nexe-Retcode: 0
X-Nexe-System: snakebin
X-Nexe-Cdr-Line: 0.543, 0.0 0.0 0 0 0 0 0 0 0 0
X-Nexe-Error: Could not resolve channel path "" for device: stdin
X-Nexe-Policy: 
X-Nexe-Validation: 0
Content-Length: 51
X-Nexe-Etag: 
Connection: close
Etag: d2b21df2f2eb8511ff68b575b9a45bb4
X-Nexe-Status: ZeroVM did not run
Date: Mon, 08 Sep 2014 11:53:19 GMT
Content-Type: text/html; charset=UTF-8
X-Chain-Total-Time: 0.544
X-Trans-Id: tx9cfb87264c9a4d0693c0a-00540d98ae

Could not resolve channel path "" for device: stdin

This kind of annoying, because it means I can't have the same app serving all types of requests for a given endpoint/endpoint space.

pkit commented 10 years ago

Looks like a bug, empty stdin should be redirected to /dev/null and no error should be raised.

larsbutler commented 10 years ago

This is resolved.