Skip to content
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

HTTP(S) Post requests to /api/contents/ with no body fail #931

Closed
dylanraws opened this issue Jul 26, 2022 · 4 comments · Fixed by #937
Closed

HTTP(S) Post requests to /api/contents/ with no body fail #931

dylanraws opened this issue Jul 26, 2022 · 4 comments · Fixed by #937
Assignees
Labels

Comments

@dylanraws
Copy link

Description

HTTP(S) POST requests to /api/contents/ that do not contain a request body currently result in an internal error:

[E 2022-07-26 04:26:38.512 ServerApp] Uncaught exception POST /api/contents/ (*.*.*.*)
    HTTPServerRequest(protocol='https', host='*.*.*.*:*', method='POST', uri='/api/contents/', version='HTTP/1.1', remote_ip='*.*.*.*')
    Traceback (most recent call last):
      File "/home/ec2-user/anaconda3/envs/MyEnvironment/lib/python3.7/site-packages/tornado/web.py", line 1713, in _execute
        result = await result
      File "/home/ec2-user/anaconda3/envs/MyEnvironment/lib/python3.7/site-packages/jupyter_server/services/contents/handlers.py", line 210, in post
        copy_from = model.get("copy_from")
    AttributeError: 'NoneType' object has no attribute 'get']

That error is thrown here:

model = self.get_json_body()
copy_from = model.get("copy_from")

The cause seems to be the following commit.

877da10#diff-36003c76c2fc08fa5e2f459696216cd66b2edd6d0bf3aff952d7555f4adbc8d9R210-R219

This is a regression from previous versions, as the previous code allowed creating a file without a request body.

To workaround, I have started passing a request body with {"type": "notebook"}.

Expected behavior

The request should cause a file to be created, and should respond with a 2xx status code.

Context

Using a custom client during automated tests to verify that the API allows creating a file.

  • Operating System and version: Amazon Linux 2
  • Browser and version: Apache HTTP client
  • Jupyter Server version: 1.18.1
@dylanraws dylanraws added the bug label Jul 26, 2022
@welcome
Copy link

welcome bot commented Jul 26, 2022

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@kevin-bates
Copy link
Member

Hi @dylanramzn - thank you for opening this issue; I agree with your assessment.

Would you like to contribute the necessary change? (Looks like an empty-bodied test would be wise as well.)

@kiersten-stokes
Copy link
Contributor

I would be interested in contributing a fix for this!

@kevin-bates
Copy link
Member

That would be great @kiersten-stokes - thank you! I've gone ahead and assigned this issue to you.

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

Successfully merging a pull request may close this issue.

3 participants