Skip to content

Commit

Permalink
feat: Clarify non-ZIP error message, closes #282
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jul 16, 2024
1 parent 8fb5ed3 commit e40d276
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Changed
API
^^^

- If the ``egg`` parameter to the :ref:`addversion.json`` webservice is not a ZIP file, use the error message, "egg is not a ZIP file (if using curl, use egg=@path not egg=path)".
- Clarify some error messages: for example, ``KeyError: 'project' (missing required parameter?)`` instead of ``'project'``, and ``exception class: message`` instead of ``message``.

CLI
Expand Down
3 changes: 3 additions & 0 deletions scrapyd/webservice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import traceback
import uuid
import zipfile
from copy import copy
from io import BytesIO

Expand Down Expand Up @@ -103,6 +104,8 @@ class AddVersion(WsResource):

def render_POST(self, txrequest):
eggf = BytesIO(txrequest.args.pop(b'egg')[0])
if not zipfile.is_zipfile(eggf):
return {"status": "error", "message": "egg is not a ZIP file (if using curl, use egg=@path not egg=path)"}
args = native_stringify_dict(copy(txrequest.args), keys_only=False)
project = args['project'][0]
version = args['version'][0]
Expand Down

0 comments on commit e40d276

Please sign in to comment.