Our case has more parts, so I reduced it to fresh install as POC. Start with fresh site install, enable jsonapi. Then:

1) Create a new content type "Composite"
2) Add an Entity Reference Field to if ("field_target_node")
3) Query content type in jsonapi based on title `http://localhost:8888/jsonapi/node/composite?sort=field_target_node.title`

With jsonapi 1.3:

{
  "data": [],
  "links": {
    "self": "http://localhost:8888/jsonapi/node/composite?sort=field_target_node.title"
  }
}

With jsonapi 1.4:

The website encountered an unexpected error. Please try again later.

[moved possibly incorrect stack trace to separate file]

_ field.field.node.composite.field_target_node.yml _

uuid: 46c895c7-2ab6-4007-b6a1-b076ed5d3f20
langcode: en
status: true
dependencies:
  config:
    - field.storage.node.field_target_node
    - node.type.article
    - node.type.composite
    - node.type.page
id: node.composite.field_target_node
field_name: field_target_node
entity_type: node
bundle: composite
label: 'Target Node'
description: ''
required: false
translatable: false
default_value: {  }
default_value_callback: ''
settings:
  handler: 'default:node'
  handler_settings:
    target_bundles:
      article: article
      page: page
    sort:
      field: _none
    auto_create: false
    auto_create_bundle: article
field_type: entity_reference

_field.storage.node.field_target_node.yml_

uuid: 1222b9ad-d615-41b1-9e29-a37ef646c86b
langcode: en
status: true
dependencies:
  module:
    - node
id: node.field_target_node
field_name: field_target_node
entity_type: node
type: entity_reference
settings:
  target_type: node
module: core
locked: false
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false

Comments

kdebisschop created an issue. See original summary.

e0ipso’s picture

Priority: Normal » Major

Thanks for the detailed report.

We will need:

  1. Create a failing test with the detailed reproduction steps provided by @kdebisschop.
  2. Fix the issue making the test above green.
gabesullice’s picture

Status: Active » Postponed (maintainer needs more info)

I've tried to replicate this issue and wasn't able to. Given the following error message:

TypeError: Argument 1 passed to Drupal\jsonapi\Routing\JsonApiParamEnhancer::__construct() must be an instance of Symfony\Component\Serializer\Normalizer\DenormalizerInterface, instance of Drupal\Core\Entity\EntityFieldManager given

This issue looks like the DI container is out of date/broken. It could be and indication that files weren't completely cleaned up during the update from 1.3 to 1.4 or that your cache hasn't yet been rebuilt.

@kdebisschop, can you completely remove jsonapi and then reinstall 1.4? Not going to 1.3 first? Then rebuild the cache?

Thanks for your help debugging this!

kdebisschop’s picture

StatusFileSize
new28.52 KB

I updated composer and then did a complete site install. The message I got is different, but it still fails. So there was something wrong about the way I tried to simply the conditions.

The trace of the new (and correct error) is attached as the full JSON and just the exception as "exception.txt". This is much better as it is a dead-on match in this test case with a fresh site install for the error we are actually seeing in development.

If it helps, I should be able to export this scheme as a module with a kernel test, or at least a functional test if not a kernel test.

d8 > composer update
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Updating drupal/jsonapi (1.3.0 => 1.4.0): Loading from cache
Writing lock file
Generating autoload files
Removing packages services cache file:
/Users/debisschop/PhpstormProjects/d8/vendor/drupal/console/extend.console.uninstall.services.yml
Creating packages services cache file: 
/Users/debisschop/PhpstormProjects/d8/vendor/drupal/console/extend.console.uninstall.services.yml
> DrupalProject\composer\ScriptHandler::createRequiredFiles
d8 > cd web
web > ../vendor/bin/drush site-install --db-url=sqlite://sites/example.com/files/.ht.sqlite
You are about to DROP all tables in your 'sites/example.com/files/.ht.sqlite' database. Do you want to continue? (y/n): y
Starting Drupal installation. This takes a while. Consider using the --notify global option.                                                                                                                                       [ok]
Installation complete.                                                                                                                                                                                                             [ok]
Congratulations, you installed Drupal!                                                                                                                                                                                             [status]
web > ../vendor/bin/drush pm-enable jsonapi
The following extensions will be enabled: jsonapi, serialization
Do you really want to continue? (y/n): y
jsonapi was enabled successfully.                                                                                                                                                                                                  [ok]
jsonapi defines the following permissions: access jsonapi resource list
serialization was enabled successfully.                                                                                                                                                                                            [ok]
web > ../vendor/bin/drush rs 8888
HTTP server listening on 127.0.0.1, port 8888 (see http://127.0.0.1:8888/), serving site default, logged in as admin...
PHP 7.1.8 Development Server started at Fri Dec 22 07:03:08 2017
Listening on http://127.0.0.1:8888
Document root is /Users/debisschop/PhpstormProjects/d8/web
....
[Fri Dec 22 07:07:32 2017] Uncaught PHP Exception Drupal\Core\Entity\Query\QueryException: "Invalid specifier 'title'" at /Users/debisschop/PhpstormProjects/d8/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php line 293
kdebisschop’s picture

Issue summary: View changes
StatusFileSize
new4.78 KB
new8.33 KB
gabesullice’s picture

Priority: Major » Normal
Status: Postponed (maintainer needs more info) » Closed (works as designed)

Hey @kdebisschop, when I was trying to replicate your example, I found the same bug and already fixed it :D

That's just been fixed and committed here: #2932266: fix(SortNormalizer): Path expansion/field resolution no longer performed for sort parameters

That means you can apply the patch or upgrade to the dev version. Thank you for your thorough bug reports, they're super helpful!

wim leers’s picture

Status: Closed (works as designed) » Closed (duplicate)
Related issues: +#2932266: fix(SortNormalizer): Path expansion/field resolution no longer performed for sort parameters