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

Unable to perform nested include in filter since @loopback-rest 5.2.0 #5872

Closed
hessman opened this issue Jul 4, 2020 · 5 comments · Fixed by #5908
Closed

Unable to perform nested include in filter since @loopback-rest 5.2.0 #5872

hessman opened this issue Jul 4, 2020 · 5 comments · Fixed by #5908
Assignees

Comments

@hessman
Copy link

hessman commented Jul 4, 2020

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

@hessman hessman added the bug label Jul 4, 2020
@dhmlau
Copy link
Member

dhmlau commented Jul 6, 2020

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

@agnes512
Copy link
Contributor

agnes512 commented Jul 6, 2020

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

@jannyHou
Copy link
Contributor

jannyHou commented Jul 9, 2020

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.

@jannyHou
Copy link
Contributor

jannyHou commented Jul 9, 2020

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 #5808 introduced coercion with spec schema for query input, that's why it starts to fail.
Submitting a fix for the scope filter.

@jannyHou jannyHou mentioned this issue Jul 9, 2020
7 tasks
@jannyHou
Copy link
Contributor

jannyHou commented Jul 9, 2020

Submitted a PR to fix it: #5908
(It's not really a regression, merging #5808 exposed the error, let's fix the error.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants