mdklatt / httpexec

Execute CLI commands over HTTP via a REST API.
MIT License
0 stars 0 forks source link

Internal server error (500) for `environment: null` in request #12

Closed mdklatt closed 5 months ago

mdklatt commented 8 months ago

Passing environment: null as part of the POST request results in an internal server error. The problem is in asgi.run():

@app.route("/<path:command>", methods=["POST"])
async def run(command: str):

    # <snip>

    # This fails for environment=None, because that will be passed to _exec() instead of an empty dict.
    env = params.get("environment", {})
    result = await _exec(argv, streams, env)

   # <snip>

An explicit value of null should be handled the same as if environment is missing. As a workaround, clients must ensure that they do not pass an explicit null for environment.

mdklatt commented 8 months ago

Commit 14e321724d7638f79d5c464fc465128099972710 is passing tests, but this needs downstream validation.

mdklatt commented 5 months ago

Issue resolved by commit 14e321724d7638f79d5c464fc465128099972710.