I've recently updated to 2.0 and I've observed that a POST request using include=image does not return the image. GET works as usual.

Is this intentional or a bug?

Comments

killes@www.drop.org created an issue. See original summary.

wim leers’s picture

Issue tags: +API-First Initiative

Hi killes! 👋 Cool to see you're using JSON:API :) Looking forward to hearing your unfiltered feedback about it: the good, the bad, the ugly.


That definitely sounds like a bug. Sorry about that! We'll need a regression test for this concrete scenario. There are lots of examples already in JsonApiRegressionTest. If you can write that test, I can promise a very fast fix. If you can't, no big deal, but then it might take a few days more.

killes@www.drop.org’s picture

Hi Wim!

I will see if I can find the time to write the test.

So far I have no major complaints about JSON API.

Were you able to replicate this? I am unsure whether it is specific to my setup.

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new1.89 KB

I doubt it is specific to your setup. Rather than reproducing it manually, it's easier to write the test coverage in your place :) Reproduced!

Now that I think about this … I'm not 100% certain this is really a bug: it might be a feature request. https://jsonapi.org/format/#fetching-includes says this is something the server may support. Are you saying that this used to work on a previous version? If so, on which version?

This seems like it's something worth supporting. But it'd be helpful to know whether this used to work and we accidentally broke it, because then I'd dig in to the issue that broke it.

wim leers’s picture

+++ b/tests/src/Functional/JsonApiRegressionTest.php
@@ -765,4 +765,46 @@ class JsonApiRegressionTest extends JsonApiFunctionalTestBase {
+   * Ensure POST and PATCH works for bundle-less relationship routes.

This comment still needs to be updated.

Status: Needs review » Needs work

The last submitted patch, 4: 3026030-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

killes@www.drop.org’s picture

Status: Needs work » Active

I do think that it used to work with v1 of JSON API.

If it is not supported, the server should IMO return a 400 and not ignore the parameter.

You may consider it a feature request to return the data.

Of course I could first do a POST without include, then do a GET with include. I'd consider that a fair workaround if you don't plan to implement this.

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new912 bytes
new1.88 KB

Status: Needs review » Needs work

The last submitted patch, 8: 3026030-8.patch, failed testing. View results

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new751 bytes
new2.59 KB

I did some archeology, and found that #2997600: Resolve included resources prior to normalization indeed broke this. If you run the test coverage in #8 against 4c23dce (the commit for #2997600) it fails, and in the preceding commit it passes.

Congrats, you're apparently the first person in over 3 months to use this feature of JSON:API 😀 👌

Status: Needs review » Needs work

The last submitted patch, 10: 3026030-10.patch, failed testing. View results

killes@www.drop.org’s picture

Despite the failed test the patch is working.

wim leers’s picture

Title: Include not working for POST? » [regression] Includes are no longer respected when POSTing/PATCHing
Status: Needs work » Needs review
StatusFileSize
new2.4 KB
new4.24 KB

No time to dig in to the reason for that failure right now. It wasn't failing locally for sure.

I realized this also was a problem for PATCH, not just POST.

Status: Needs review » Needs work

The last submitted patch, 13: 3026030-13.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new1.25 KB
new4.27 KB

LOL. node entity type's weird permissions still trip me up after more than a decade. 😵

wim leers’s picture

StatusFileSize
new2.4 KB
new4.21 KB

Cleaning up & make stricter.

wim leers’s picture

StatusFileSize
new3.07 KB

This should fail.

Status: Needs review » Needs work

The last submitted patch, 17: 3026030-16-tests_only_FAIL.patch, failed testing. View results

  • Wim Leers committed 5d3a568 on 8.x-2.x
    Issue #3026030 by Wim Leers, killes@www.drop.org: [regression] Includes...
wim leers’s picture

Status: Needs work » Fixed

Test-only patch in #17 is failing, #16 is passing. I don't see why I'd need to wait for @e0ipso or @gabesullice to RTBC/commit this since this involves a one-line fix + test coverage for a regression.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rpayanm’s picture

Project: JSON:API » Drupal core
Version: 8.x-2.x-dev » 8.9.x-dev
Component: Code » jsonapi.module

Moving to Drupal core's issue queue.

I'm working on https://www.drupal.org/project/drupal/issues/3122113