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

Error renaming dataset due to missing content-type header #213

Closed
hexylena opened this issue Mar 15, 2017 · 5 comments
Closed

Error renaming dataset due to missing content-type header #213

hexylena opened this issue Mar 15, 2017 · 5 comments
Labels

Comments

@hexylena
Copy link
Member

Against 17.01, I saw the following error server side:

File '/galaxy/lib/galaxy/web/framework/middleware/error.py', line 239 in __next__
  return next(self.app_iterator)
File '/galaxy/lib/galaxy/web/framework/middleware/sentry.py', line 39 in __call__
  iterable = self.application(environ, start_response)
File '/galaxy/.venv/local/lib/python2.7/site-packages/paste/recursive.py', line 85 in __call__
  return self.application(environ, start_response)
File '/galaxy/lib/galaxy/web/framework/middleware/remoteuser.py', line 87 in __call__
  return self.app( environ, start_response )
File '/galaxy/.venv/local/lib/python2.7/site-packages/paste/httpexceptions.py', line 640 in __call__
  return self.application(environ, start_response)
File '/galaxy/lib/galaxy/web/framework/base.py', line 134 in __call__
  return self.handle_request( environ, start_response )
File '/galaxy/lib/galaxy/web/framework/base.py', line 193 in handle_request
  body = method( trans, **kwargs )
File '/galaxy/lib/galaxy/web/framework/decorators.py', line 246 in decorator
  kwargs['payload'] = __extract_payload_from_request(trans, func, kwargs)
File '/galaxy/lib/galaxy/web/framework/decorators.py', line 168 in __extract_payload_from_request
  content_type = trans.request.headers[ 'content-type' ]
File '/galaxy/.venv/local/lib/python2.7/site-packages/webob/headers.py', line 139 in __getitem__
  return self.environ[_trans_name(hname)]
KeyError: 'CONTENT_TYPE'

here galaxy checks for that header and errors if missing. I found a workaround by patching my make_put_request to add a header with application/json, but I'm not sure this is the "correct" solution, so filing a bug here.

the affected bioblend call is:

gi.histories.update_dataset(hist['id'], dataset['id'], name="new-dataset-name")
@gregvonkuster
Copy link

May be related to this galaxyproject/galaxy#2551

@hexylena
Copy link
Member Author

@gregvonkuster yep! Looks like the same error exactly. Wow, no one has tried to rename datasets in the API since 16.04? Or we just all re-invent the same workarounds?

@gregvonkuster
Copy link

Likely both! ;)

@nsoranzo
Copy link
Member

Are you both using external auth? We have a test for gi.histories.update_dataset() and it has always passed.
@erasche solution should be correct, I'll apply the following patch if you can confirm it fixes the issue for you:

diff --git a/bioblend/galaxyclient.py b/bioblend/galaxyclient.py
index 01f836d..3cf7885 100644
--- a/bioblend/galaxyclient.py
+++ b/bioblend/galaxyclient.py
@@ -174,7 +174,8 @@ class GalaxyClient(object):
             params = self.default_params
 
         payload = json.dumps(payload)
-        r = requests.put(url, verify=self.verify, data=payload, params=params)
+        headers = self.json_headers
+        r = requests.put(url, data=payload, params=params, headers=headers, verify=self.verify)
         if r.status_code == 200:
             try:
                 return r.json()

@nsoranzo nsoranzo added the bug label Mar 15, 2017
@hexylena
Copy link
Member Author

Yes, using external auth. Yes, confirmed, that patch does fix it.

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

No branches or pull requests

3 participants