Loopback-next: Unable to perform nested include in filter since @loopback-rest 5.2.0

Created on 4 Jul 2020  路  5Comments  路  Source: strongloop/loopback-next

Hi loopback team !

The last publish seems to have introduced a regression.

Steps to reproduce

  • Upgrade to @loopback-rest 5.2.0
  • Use PostgreSQL datasource with the loopback connector
  • Create models, repositories with relations.
  • Create simple controllers to perform a find or findById
  • Do a query with nested include :
{
  "include": [
    {
      "relation": "relation0",
      "scope": {
        "include": [
          {
            "relation": "relation0relation0",
            "scope": {
              "include": [
                {
                  "relation": "relation0relation0relation0"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "relation": "relation1"
    },
    {
      "relation": "relation2"
    }
  ]
}

Current Behavior

A Bad Request 400 error :

{
  "error": {
    "statusCode": 400,
    "name": "BadRequestError",
    "message": "Invalid value.",
    "details": [
      {
        "path": "/include/0/scope",
        "code": "additionalProperties",
        "message": "should NOT have additional properties",
        "info": {
          "additionalProperty": "include"
        }
      }
    ]
  }
}

We can not use "include" inside "scope".

Expected Behavior

The queried model with all his queried relations (and relation's relations).

Link to reproduction sandbox

in progress

Additional information

Related Issues

bug interrupt regression

Most helpful comment

Submitted a PR to fix it: https://github.com/strongloop/loopback-next/pull/5908
(It's not really a regression, merging #5808 exposed the error, let's fix the error.)

All 5 comments

@agnes512, I believe you were looking into some issues on the filter. Could you please take a look as well? Thanks.

@dhmlau this is causing by the change we made in #5808 . cc @jannyHou

The 1st level schema has include property:
Screen Shot 2020-07-09 at 10 37 04 AM
While the 2nd level schema somehow doesn't have it:
Screen Shot 2020-07-09 at 10 37 29 AM

Investigating.

I think the generated TodoList.ScopeFilter should also have include property. It passed before because we only validate request body but not object in query.
PR https://github.com/strongloop/loopback-next/pull/5808 introduced coercion with spec schema for query input, that's why it starts to fail.
Submitting a fix for the scope filter.

Submitted a PR to fix it: https://github.com/strongloop/loopback-next/pull/5908
(It's not really a regression, merging #5808 exposed the error, let's fix the error.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kesavkolla picture kesavkolla  路  3Comments

milindsingh picture milindsingh  路  3Comments

teambitcodeGIT picture teambitcodeGIT  路  3Comments

shadyanwar picture shadyanwar  路  3Comments

cloudwheels picture cloudwheels  路  3Comments