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

InvalidContentTypeError on attempting PATCH: application/vnd.api+json #8029

Closed
DIzFer opened this issue Sep 6, 2018 · 9 comments
Closed

Comments

@DIzFer
Copy link

DIzFer commented Sep 6, 2018

When upgrading from ember-cli@3.3.0 to 3.4.0, issuing ember serve --proxy returns InvalidContentTypeError every time I attempt to PATCH to the proxyed API. The initial GET appears to work fine. Since I have a working environment, I will proceed now to paste both working and broken outputs from specified commands and the ember serve output.

Working


Output from ember version --verbose && npm --version && yarn --version:

$ ember version --verbose
ember-cli: 3.3.0
http_parser: 2.7.1
node: 8.10.0
v8: 6.2.414.50
uv: 1.18.0
zlib: 1.2.11
ares: 1.14.0
modules: 57
nghttp2: 1.30.0
openssl: 1.1.0g
icu: 60.2
unicode: 10.0
cldr: 32.0.1
tz: 2017c
os: linux x64

$ npm --version
3.5.2

$ yarn --version
zsh: command not found: yarn

$ ember serve --proxy=http://localhost:8080
Proxying to http://localhost:8080
/home/.../app/validations/dnsRecord.js
  3:2  error  'validateNumber' is defined but never used  no-unused-vars
✖ 1 problem (1 error, 0 warnings)
Build successful (3001ms) – Serving on http://localhost:4200/
Slowest Nodes (totalTime => 5% )              | Total (avg)
----------------------------------------------+---------------------
Package /assets/vendor.js (1)                 | 744ms
Rollup (1)                                    | 366ms
broccoli-persistent-filter:EslintValid... (3) | 273ms (91 ms)
Babel: lodash (1)                             | 197ms
broccoli-persistent-filter:SimpleReplace (3)  | 183ms (61 ms)
Funnel (31)                                   | 165ms (5 ms)
Funnel: Addon JS (35)                         | 151ms (4 ms)
GET /api/v1/main-model?include=relationship%2Crelationship.nested 200 30.154 ms - -
GET /api/v1/main-model/8 200 9.587 ms - 380
PATCH /api/v1/main-model/8 200 17.497 ms - 416

Broken


$ ember version --verbose
WARNING: 
WARNING: /home/.../node_modules/ember-cli-broccoli-sane-watcher/node_modules/sane:
WARNING:    Missing dependency 'fsevents'
WARNING: 
WARNING: /home/.../node_modules/qunit/node_modules/sane:
WARNING:    Missing dependency 'fsevents'
WARNING: 
WARNING: /home/.../node_modules/sane:
WARNING:    Missing dependency 'fsevents'
WARNING: 
WARNING: /home/.../node_modules/simple-html-tokenizer/commands:
WARNING:    Missing package directory
ember-cli: 3.4.1
http_parser: 2.7.1
node: 8.10.0
v8: 6.2.414.50
uv: 1.18.0
zlib: 1.2.11
ares: 1.14.0
modules: 57
nghttp2: 1.30.0
openssl: 1.1.0g
icu: 60.2
unicode: 10.0
cldr: 32.0.1
tz: 2017c
os: linux x64

# npm and yarn status unchanged
WARNING:
WARNING: /home/.../node_modules/ember-cli-broccoli-sane-watcher/node_modules/sane:
WARNING:    Missing dependency 'fsevents'
WARNING:
WARNING: /home/.../node_modules/qunit/node_modules/sane:
WARNING:    Missing dependency 'fsevents'
WARNING:
WARNING: /home/.../node_modules/sane:
WARNING:    Missing dependency 'fsevents'
WARNING:
WARNING: /home/.../node_modules/simple-html-tokenizer/commands:
WARNING:    Missing package directory
DEPRECATION: Ember will stop including jQuery by default in an upcoming version. If you wish keep using jQuery in your application explicitly add `@ember/jquery` to your package.json
Proxying to http://localhost:8080
/home/.../app/validations/dnsRecord.js
  3:2  error  'validateNumber' is defined but never used  no-unused-vars
✖ 1 problem (1 error, 0 warnings)
Build successful (17102ms) – Serving on http://localhost:4200/
Slowest Nodes (totalTime => 5% )              | Total (avg)
----------------------------------------------+---------------------
Babel: lodash (1)                             | 3662ms
Babel: ember-data (2)                         | 2529ms (1264 ms)
Babel: ember-test-helpers (2)                 | 1527ms (763 ms)
Babel: cdn-ui (2)                             | 1439ms (719 ms)
GET /api/v1/main-model?include=relationship%2Crelationship.nested 200 31.385 ms - -
GET /api/v1/main-model/8 200 14.955 ms - 381
InvalidContentTypeError: Could not parse content type header: application/vnd.api+json
    at createError (/home/.../node_modules/error/typed.js:31:22)
    at anyBody (/home/.../node_modules/body/any.js:36:18)
    at Server.handler (/home/.../node_modules/tiny-lr/src/server.js:165:32)
    at Layer.handle [as handle_request] (/home/.../node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/.../node_modules/express/lib/router/index.js:317:13)
    at /home/.../node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/home/.../node_modules/express/lib/router/index.js:335:12)
    at next (/home/.../node_modules/express/lib/router/index.js:275:10)
    at compression (/home/.../node_modules/compression/index.js:220:5)
    at Layer.handle [as handle_request] (/home/.../node_modules/express/lib/router/layer.js:95:5)

This is shown in Firefox's console:

XHR PATCH http://localhost:4200/api/v1/main-model/8
[HTTP/1.1 415 Unsupported Media Type 9ms]
Error: Ember Data Request PATCH /api/v1/main-model/8 returned a 415
Payload (text/html; charset=utf-8)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>InvalidContentTypeError: Could not parse content type header: application/vnd.api+json<br> &nbsp; &nbsp;at createError (/home/.../node_modules/error/typed.js:31:22)<br> &nbsp; &nbsp;at anyBody (/home/.../node_modules/body/any.js:36:18)<br> &nbsp; &nbsp;at Server.handler (/home/.../node_modules/tiny-lr/src/server.js:165:32)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/home/.../node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at trim_prefix (/home/.../node_modules/express/lib/router/index.js:317:13)<br> &nbsp; &nbsp;at /home/.../node_modules/express/lib/router/index.js:284:7<br> &nbsp; &nbsp;at Function.process_params (/home/.../node_modules/express/lib/router/index.js:335:12)<br> &nbsp; &nbsp;at next (/home/.../node_modules/express/lib/router/index.js:275:10)<br> &nbsp; &nbsp;at compression (/home/.../node_modules/compression/index.js:220:5)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/home/.../node_modules/express/lib/router/layer.js:95:5)</pre>
</body>
</html>
@DIzFer
Copy link
Author

DIzFer commented Sep 6, 2018

Additional note: this was found when using ember-cli-update to update everything to 3.4.0. Since, after encountering this issue, I could not find the usual Release Notes blogpost over at emberjs.com, I reverted everything I could, which left me with the issue, caused by the fact that ember-cli is the only item in package.json that is allowed to update minor versions. The above shown version switching was done by alternating between "3.3.0" and "^3.3.0" in my package.json. If required, I may post logs after a full upgrade, but they are just more verbose due to additional linting.

@cah-brian-gantzler
Copy link

My POST to my authenticate rest end-point is also failing. Unsure where the actual problem is. It appears as if the body of the post is all zeros. Switching only from ember-cli 3.3.0 to 3.4.1 (in the package.json) causes my issue. While not the same, it does seems similar. Proxying seems to be messing up something in the request

@cibernox
Copy link
Contributor

I have the exact same problem with the built in proxy, but with POST requests as well.

@twokul twokul mentioned this issue Sep 11, 2018
4 tasks
@cibernox
Copy link
Contributor

Just to give an update on this isuse, the problem is in the live reload implementation.

ember serve --no-live-reload can be a temporary workaround.

@DIzFer
Copy link
Author

DIzFer commented Sep 12, 2018

Just to give an update on this isuse, the problem is in the live reload implementation.

ember serve --no-live-reload can be a temporary workaround.

I can confirm this works on my project with ember-cli 3.4.1.

@rwjblue
Copy link
Member

rwjblue commented Sep 12, 2018

Awesome, thank you!

@cah-brian-gantzler
Copy link

Confirming the --no-live-reload is a temporary fix for my problem as well.

@rwjblue
Copy link
Member

rwjblue commented Sep 12, 2018

Fixed by #8038 and released in v3.4.2.

@rwjblue rwjblue closed this as completed Sep 12, 2018
@DIzFer
Copy link
Author

DIzFer commented Sep 12, 2018

Fixed indeed. Thank you very much!

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

4 participants