Forums

API webapps DELETE error 500

I tried to use the API to DELETE https://www.pythonanywhere.com/api/v0/user/javabrett/webapps/javabrett.pythonanywhere.com/ . All of GET /webapps/ , GET /webapps/javabrett.pythonanywhere.com/ and POST /webapps/javabrett.pythonanywhere.com/reload/ work fine . Token auth is working fine. DELETE https://www.pythonanywhere.com/api/v0/user/javabrett/webapps/javabrett.pythonanywhere.com/ yields:

<div class="container">
                <div class="row">
                    <div class="col-md-8 col-md-offset-2">
                        <h1 class="error_header" id="id_server_error_title">Server Error :-/</h1>
                        <div id="id_server_error_text">
                            <p>An error has occurred. This shouldn't happen</p>
                            <p>
            Feel free to contact your nearest PythonAnywhere
            representative (there's a "Send feedback" link above), and
            loudly complain about the problem.
          </p>
                            <p>(Extra credit if you do so in rhyming verse!)</p>
                        </div>
                        <p>
                            <a id="id_link_home" href="/">&laquo; Return to PythonAnywhere home</a>
                        </p>
                    </div>
                </div>
            </div>

OK, here's the verse

Thanks for reporting that and for the fantastic poem :-)

It looks like you've found a bug in the delete code. When you delete a website, it tries to move the WSGI file (in your case, /var/www/javabrett_pythonanywhere_com_wsgi.py) to one side as a backup. But it looks like the code path that does that doesn't handle symlinks correctly; I'm guessing that you replaced the generated WSGI file with a symlink to your own one (perhaps in your source tree).

If you replace the symlink with a regular file, it will work. I'll add a ticket for this bug.

Thanks for pinpointing the cause so quickly!

Indeed I had symlinked that file - I think it is useful to keep it under source-code-control (Git), and to only have a single copy, that way a git checkout and reload will always provide an up-to-date deployment, without worrying about a second copy of that file or it going stale, or bothering with additional console/copy operations.

But I have an effective workaround now - for a full webapp delete (versus refresh/reload), just make sure to remove/replace that symlink before calling DELETE.

Probably good to update this thread when the bug is fixed. Verse also updated :).

Thanks again! Brett

Yes, I've added a link to this forum topic to the ticket in our task-tracker so we'll definitely post back here once we have a fix.

You should consider a second career as a poet :-)