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

Fix error that prevents posting to api/contents endpoint with no body #937

Merged
merged 3 commits into from
Jul 29, 2022

Conversation

kiersten-stokes
Copy link
Contributor

@kiersten-stokes kiersten-stokes commented Jul 29, 2022

Fixes #931

This is a small refactor to avoid a 'NoneType' AttributeError when sending a POST request to api/contents that does not include a body.

A body-less POST to the api/contents/{path} endpoint is also added to services/contents/test_api.py:test_create_untitled.

@welcome
Copy link

welcome bot commented Jul 29, 2022

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Copy link
Member

@kevin-bates kevin-bates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - confirmed the test reproduces the issue prior to this change and the changes fix the issue. Thanks @kiersten-stokes!

@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2022

Codecov Report

Merging #937 (2b1126c) into main (f373286) will decrease coverage by 0.07%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #937      +/-   ##
==========================================
- Coverage   72.28%   72.20%   -0.08%     
==========================================
  Files          65       65              
  Lines        8002     8001       -1     
  Branches     1336     1333       -3     
==========================================
- Hits         5784     5777       -7     
- Misses       1811     1814       +3     
- Partials      407      410       +3     
Impacted Files Coverage Δ
jupyter_server/services/contents/handlers.py 86.63% <100.00%> (+0.99%) ⬆️
jupyter_server/services/contents/filemanager.py 70.61% <0.00%> (-0.79%) ⬇️
jupyter_server/services/kernels/kernelmanager.py 77.99% <0.00%> (-0.65%) ⬇️
jupyter_server/serverapp.py 65.48% <0.00%> (-0.19%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f373286...2b1126c. Read the comment docs.

@blink1073 blink1073 merged commit 426d996 into jupyter-server:main Jul 29, 2022
@welcome
Copy link

welcome bot commented Jul 29, 2022

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

@blink1073
Copy link
Contributor

@meeseeksdev please backport to 1.x

@lumberbot-app
Copy link

lumberbot-app bot commented Jul 29, 2022

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 1.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 426d9968233dc905b7909fdf98e87c5fe7069221
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #937: Fix error that prevents posting to `api/contents` endpoint with no body'
  1. Push to a named branch:
git push YOURFORK 1.x:auto-backport-of-pr-937-on-1.x
  1. Create a PR against branch 1.x, I would have named this PR:

"Backport PR #937 on branch 1.x (Fix error that prevents posting to api/contents endpoint with no body)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

await self._copy(copy_from, path)
else:
await self._new_untitled(path, type=type, ext=ext)
await self._new_untitled(path, type=type, ext=ext)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this path only trigger if copy_from is false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shoot, yeah good catch - looks like a follow-up is in order!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vidartf - I apologize for not catching this as well.

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

Successfully merging this pull request may close these issues.

HTTP(S) Post requests to /api/contents/ with no body fail
5 participants