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 while using datastore API is host header is present #3920

Open
mkalish opened this issue Nov 13, 2017 · 4 comments
Open

Error while using datastore API is host header is present #3920

mkalish opened this issue Nov 13, 2017 · 4 comments
Assignees

Comments

@mkalish
Copy link

mkalish commented Nov 13, 2017

CKAN Version if known (or site URL)

{
ckan_version: "2.7.2",
site_url: "http://data.codefordc.org",
site_description: "",
site_title: "Code For DC - Open Data Portal",
error_emails_to: null,
locale_default: "en",
extensions: [
  "stats",
  "text_view",
  "image_view",
  "recline_view",
  "recline_grid_view",
  "recline_graph_view",
  "recline_map_view",
  "datastore",
  "resource_proxy",
  "datapusher",
  "open_data_dc",
  "showcase",
  "geojson_view",
  "pdf_view",
  "datarequests"
]
}

Please describe the expected behaviour

Navigate to preview a resource that has been uploaded to the datastore and I expect to see a preview load
On http://data.codefordc.org/dataset/neighborhood-school-attendance-cluster-mapping/resource/55820a22-4b91-4d10-9300-48d3d5792497:
screen shot 2017-11-13 at 6 30 09 pm

Please describe the actual behaviour

The preview does not load and there is an error in the network tab.
screen shot 2017-11-13 at 6 24 37 pm

Logs that occur are:

[Mon Nov 13 23:25:53.357071 2017] [:error] [pid 4039:tid 140501469529856] [remote 127.0.0.1:13843] mod_wsgi (pid=4039): Exception occurred processing WSGI script '/etc/ckan/default/apache.wsgi'.
[Mon Nov 13 23:25:53.357112 2017] [:error] [pid 4039:tid 140501469529856] [remote 127.0.0.1:13843] TypeError: expected byte string object for header name, value of type unicode found

What steps can be taken to reproduce the issue?

By process of elimination, I determined that the origin header is the problem:

(Causes error)

curl 'http://data.codefordc.org/api/3/action/datastore_search' \
    -H 'Origin: http://data.codefordc.org' \ 
    -H 'Accept-Encoding: gzip, deflate' \
    -H 'Accept-Language: en-US,en;q=0.8' \
    -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36' \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    -H 'Accept: */*' \
    -H 'Referer: http://data.codefordc.org/dataset/dc-cas-results-by-ward/resource/67e9b94e-9f7e-4bdf-a5ff-743b56d627f8/view/bc377ef9-60f1-4976-8ff3-2d7e30a06836' \
    -H 'X-Requested-With: XMLHttpRequest' \
    -H 'Connection: keep-alive' \
    -H 'DNT: 1' --data '%7B%22resource_id%22%3A%2267e9b94e-9f7e-4bdf-a5ff-743b56d627f8%22%2C%22filters%22%3A%7B%7D%2C%22limit%22%3A10%2C%22offset%22%3A0%7D' 

versus:
(Works)

curl 'http://data.codefordc.org/api/3/action/datastore_search' \
    -H 'Accept-Encoding: gzip, deflate' \
    -H 'Accept-Language: en-US,en;q=0.8' \
    -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36' \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    -H 'Accept: */*' \
    -H 'Referer: http://data.codefordc.org/dataset/dc-cas-results-by-ward/resource/67e9b94e-9f7e-4bdf-a5ff-743b56d627f8/view/bc377ef9-60f1-4976-8ff3-2d7e30a06836' \
    -H 'X-Requested-With: XMLHttpRequest' \
    -H 'Connection: keep-alive' \
    -H 'DNT: 1' --data '%7B%22resource_id%22%3A%2267e9b94e-9f7e-4bdf-a5ff-743b56d627f8%22%2C%22filters%22%3A%7B%7D%2C%22limit%22%3A10%2C%22offset%22%3A0%7D' 

I'm only observing this in Chrome and Safari currently as it seems that firefox does not include the origin header.

http://data.codefordc.org/dataset/neighborhood-school-attendance-cluster-mapping/resource/55820a22-4b91-4d10-9300-48d3d5792497 in firefox
screen shot 2017-11-13 at 6 30 57 pm

I recently upgraded CKAN and only noticed this problem after that.

@wardi wardi self-assigned this Nov 14, 2017
@mkalish
Copy link
Author

mkalish commented Dec 13, 2017

Any updates on this or any other information needed from me?

@mkalish
Copy link
Author

mkalish commented Feb 20, 2018

Any thoughts on this? I'm wondering if this something that I've set up wrong.

@wardi
Copy link
Contributor

wardi commented Feb 20, 2018

This is the first issue I've dealt with regarding the Origin header. Could it be related to a CORS setting on your server?

@fabiankirstein
Copy link
Contributor

I can confirm this issue. I have installed a plain 2.7.2 and deployed it with Apache as described in the documentation. When using the API with a set Origin header field CKAN throws the "TypeError". After downgrading to 2.6.4 it works fine again. It may be related to this issue: #3921

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

No branches or pull requests

3 participants