Skip to content

Returning from a function without $return or "out" bindings #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1st1 opened this issue Mar 6, 2018 · 2 comments
Closed

Returning from a function without $return or "out" bindings #74

1st1 opened this issue Mar 6, 2018 · 2 comments

Comments

@1st1
Copy link
Collaborator

1st1 commented Mar 6, 2018

For a function with the following function.json:

{
  "scriptFile": "main.py",
  "disabled": false,
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req"
    }
  ]
}

and the following implementation:

def main(req):
    return 'OK'

The Web Host / Python worker currently return HTTP 204 No Content status. This is confusing, as a user would expect to see an HTTP 200 status with "OK" response.

I propose to raise an error in cases like this and return HTTP 500.

We've discussed an alternative solution of throwing a warning in cases like this before, but I'd really prefer this to be an error. Warnings are frequently ignored by Python users so it's possible that a lot of users will spent a lot of time trying to figure out why they get 204 messages. Returning an error exposes the problem in a visible and an easily fixable way (and that's how we usually deal with situation like this in Python).

/cc @asavaritayal @christopheranderson @pragnagopa @elprans @brettcannon

@brettcannon
Copy link
Member

"Errors should never pass silently" 😁

@1st1
Copy link
Collaborator Author

1st1 commented Mar 8, 2018

Closing this one now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants