Hi all,
I'm getting below error. I configured relaxed between two remote sites.
Client error: `GET http://replicator:***@cddemo10.ode52.dd:8083/relaxed` resulted in a `406 Not Acceptable` response: < html lang="en" dir="ltr" prefix="content: http://purl.org/rss/1.0/modules/content/ dc: http://purl.org (truncated...)
Client error: `GET http://replicator:***@cddemo10.ode52.dd:8083/relaxed/_all_dbs` resulted in a `406 Not Acceptable` response: < html lang="en" dir="ltr" prefix="content: http://purl.org/rss/1.0/modules/content/ dc: http://purl.org (truncated...)
Please help me to fix it.
Update: These error happens because of the changes in Drupal 8.5.x core.
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | 2955317-24.patch | 19.72 KB | jeqq |
| #19 | core-2955317-fix_json_issue.patch | 704 bytes | vg42 |
| #19 | add_format-2955317-fix_json_issue.patch | 1.71 KB | vg42 |
| #17 | redirect-2955317-format-json-issue.patch | 2.7 KB | vg42 |
Comments
Comment #2
manojthe1 commentedComment #3
manojthe1 commentedClient error: `GET http://replicator:***@mysite.com/relaxed` resulted in a `404 Not Found` response:
Client error: `GET http://replicator:***@mysite.com/relaxed/_all_dbs` resulted in a `404 Not Found` response:
Comment #4
manojthe1 commentedComment #5
manojthe1 commentedComment #6
manojthe1 commentedComment #7
polynya commentedThere are some related issues, for example #2937942: REST views: regression in 8.5.x: view with display using 'csv' format now returns a 406 response, need to add ?_format=csv to URL to make it work
Drupal core 8.5.0 introduced a change (arguably a bug fix) which forces REST requests to specify the format in the query string, for example,
_format=jsonHere's a change record
I'm not sure what the best solution for Relaxed is. I'm waiting to see how the discussions on the core issues go.
Comment #8
jeqq commentedComment #9
jeqq commentedI started to do some work on this but it's still work in Progress https://github.com/relaxedws/drupal-relaxed/pull/97. Maybe will get back to it next week.
Comment #10
jeqq commentedComment #11
wim leersComment #12
wim leersNote that #2854543: NegotiationMiddleware calls $request->setRequestFormat('html') when there is no _format request parameter, but shouldn't would make the break less bad, or even make it disappear altogether. That being said, it looks like
relaxedalso make the mistake of relying on debug-only behavior (see #2937942: REST views: regression in 8.5.x: view with display using 'csv' format now returns a 406 response, need to add ?_format=csv to URL to make it work's comments of March 14 and later), rather than specifying the?_formatquery string as Drupal 8 has always mandated.Comment #13
timmillwood@Wim Leers - We can't add a
?_formatquery string because relaxed needs to be compatible with the CouchDB endpoints, which don't have this query string.Comment #14
orkutmuratyilmazAny update?
Comment #15
timmillwoodNot yet, but patches stemming from the PR in #9 are welcome.
Comment #16
vg42 commentedI'm working on this issue #Nashville2018.
Comment #17
vg42 commentedHi.
My idea is to redirect requests to new URL with a query parameter _format=json
I've added new EventSubscriber (please find parch in attached file). When I open URL from a browser or Postman - it works fine (even if there are authentication credentials), but when I try to connect from another Drupal installation I see an error:
GuzzleHttp\Exception\ClientException: Client error: `GET http://admin:***@drupal8b.docksal/relaxed` resulted in a `401 Unauthorized` response: {"message":"No authentication credentials provided."} in GuzzleHttp\Exception\RequestException::create() (line 113 of /var/www/docroot/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php).
It seems that GuzzleHttp doesn't handle a redirect correctly. Now I'm looking for a solution.
Comment #18
vg42 commentedRedirects will not work. CouchDB tries to handle redirects, but while redirecting it loses query parameters:
location from the response: http://drupal8.docksal/relaxed/drupal8b?_format=json
will be redirected to http://drupal8.docksal/relaxed/drupal8b
You can see here:
https://github.com/relaxedws/couchdb-client/blob/master/lib/Doctrine/Cou...
The only 'path' without query parameters is used.
Comment #19
vg42 commentedI finally have found a solution. But it needs to patch Drupal Core. I've found that CouchDB adds header 'Content-type: application/json' to each request, so I've added one more condition to getContentType method for NegotiationMiddleware class. And now if the header is present, the format will be set to 'json'.
In attached files there are 2 patches:
The first patch adds _format=json to all requests which are done from Relaxed module.
The second one adds a new condition to Drupal Core.
Comment #20
jeqq commented@vg42 Don't forget to change the issue status to "Needs review" when needed.
Comment #21
jeqq commentedAfter the discussion we had with Wim, he suggested to take a look at this issue #2854543: NegotiationMiddleware calls $request->setRequestFormat('html') when there is no _format request parameter, but shouldn't it might be what we need to fix the problem we have with the _format parameter.
Comment #22
wim leersYep. I'm currently working on a review/reroll of it, but would be great to get review support from you, to get it to RTBC and committed ASAP.
Note I already pointed to it in #11.
Comment #23
gabesulliceHi all, coming here from #2854543 and the JSON API team. We've bypassed the
_formatrequirement in the JSON API module using our own middleware:https://cgit.drupalcode.org/jsonapi/tree/src/StackMiddleware
and that is activated by:
https://cgit.drupalcode.org/jsonapi/tree/src/JsonapiServiceProvider.php
Comment #24
jeqq commentedFinally had a chance to work on this. The solution is using a middleware that sets the request format. The idea is taken form JSON API module, as @Wim Leers and @gabesullice proposed in some discussions. With this patch all resources can be accessed and replication works.
Two tests are still failing but those fails are related to some other changes in 8.5.x. A patch with the fix for those will come next.
Results in Travis CI: https://travis-ci.org/relaxedws/drupal-relaxed/builds/376313349
Comment #26
jeqq commentedWe have now just one failing tests because of this core issue: #2972988: Error when saving a denormalized entity with text fields with "processed" property.
Comment #27
wim leers#2854543: NegotiationMiddleware calls $request->setRequestFormat('html') when there is no _format request parameter, but shouldn't landed in core. Are you sure this is still necessary?
Comment #28
wim leersAlso, wrt how this reuses
rest.module's functionality: comments welcome on #2822201: Allow contrib modules to deploy REST resources by creating routes, removing the need for config entities in that special case, which is about exactly that, and nearly unblocked!Comment #29
jeqq commentedFrom #27
Yes, this is still necessary. Recent core patches don't fix the issues we have in Relaxed.
Comment #31
jeqq commentedNow we need #2972988: Error when saving a denormalized entity with text fields with "processed" property to get fixed and commited.
Comment #32
wim leersHm.
Reviewing post-commit because the issue was marked , not , which is why I didn't review it.
All these default config changes actually are out-of-scope — they are unrelated to the problem at hand. They should've been in a separate commit. That's just optional clean-up that could've happened a long time ago. Perhaps I'm overlooking the reason for making this change now/here?
Same here.
It's not at all clear to me which of the changes were absolutely necessary to unbreak the module in 8.5.
Most worryingly … no test coverage at all. If there had been a patch with a failing test on this issue, I'd have chimed in. Because then I could see what exactly was not working and could figure out why. But more importantly, no tests means that a future regression in this area will again mean we only find out AFTER core has shipped a new release. Contrib modules have been able for years now to set up automated testing against the next core minor's branch, and hence be notified many months in advance of potential breakage. So early in fact, that core will instantly roll back the commit that broke it!
Comment #33
jeqq commented@Wim Leers thanks for the review!
1. and 2. I agree that those changes are not relevant to this issue, they were some experiments and should have go in a separate commit or not be done at all.
About the testing: we have more testing that run in Travis CI and it covers the issue we fixed here: https://travis-ci.org/relaxedws/drupal-relaxed/builds/380067540 (now we have 2 tests failing with Drupal 8.5.x because of the core issue).
A build before this fix: https://travis-ci.org/relaxedws/drupal-relaxed/builds/374832476
A build after this fix: https://travis-ci.org/relaxedws/drupal-relaxed/builds/380067540