elide icon indicating copy to clipboard operation
elide copied to clipboard

Cryptic error message on data passed to child entity

Open codingwhatever opened this issue 5 years ago • 3 comments

Model

public class Incident {
    @ManyToOne
    @JoinColumn(name = "last_edited_by")
    @CreatePermission(expression = Constants.USER_VALID)
    @UpdatePermission(expression = Constants.USER_VALID)
    private User last_edited_by;
    ...
}

public class User {
    private String id;
    ...
}

Expected Behavior

Request:

{
"query": "mutation {incidents(op: UPSERT, data: {}) { last_edited_by(op: UPSERT data: {id:\"invalidUserId\"}) { edges { node { id } } }   } } } }"
}

Reasonable response:

{
  "data": null,
  "errors": [
    {
      "message": "Exception while fetching data (/incidents/edges[0]/node/last_edited_by) : null",
      "locations": [
        {
          "line": 1,
          "column": 358
        }
      ],
      "path": [
        "incidents",
        "edges",
        0,
        "node",
        "last_edited_by"
      ]
    }
  ]
}

Current Behavior

When passing data values to child entity from the parent entity's data, the response is cryptic. Broken request:

{
"query": "mutation {incidents(op: UPSERT, data: {created_by: {id:\"invalidUserId\"}}) { last_edited_by { edges { node { id } } }   } } } }"
}

Broken response:

{
  "data": null,
  "errors": [
    {
      "message": "Exception while fetching data (/incidents) : null",
      "locations": [
        {
          "line": 1,
          "column": 79
        }
      ],
      "path": [
        "incidents"
      ]
    }
  ]
}

Stacktrace:

2020-07-29 22:01:33.238 +0000 [qtp288615534-335] [App, ] DEBUG com.yahoo.elide.graphql.QueryRunner.executeGraphQLRequest - WebApplicationException
javax.ws.rs.WebApplicationException: HTTP 200 OK
        at com.yahoo.elide.graphql.QueryRunner.executeGraphQLRequest(QueryRunner.java:191)
        at com.yahoo.elide.graphql.QueryRunner.lambda$run$0(QueryRunner.java:104)
        at com.yahoo.elide.graphql.QueryRunner.run(QueryRunner.java:139)
        at com.yahoo.elide.spring.controllers.GraphqlController.post(GraphqlController.java:58)

Possible Solution

Steps to Reproduce (for bugs)

  1. Create table with Data Model listed above.
  2. Send a mutation request as specified above.

Context

Difficult to debug invalid insert values.

Your Environment

  • Elide version used: 4.64
  • Environment name and version (Java 1.8.0_152): OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
  • Operating System and version: RHEL 7
  • Link to your project:

codingwhatever avatar Jul 29 '20 22:07 codingwhatever

@codingwhatever GraphQL error handling was improved greatly in Elide 5. Can you rerun with Elide 5?

aklish avatar Aug 04 '21 19:08 aklish

@codingwhatever what was the actual error in this case? Did it fail for permissions or are you providing an invalid user ID? I"m not sure how to reproduce the failure in this case.

aklish avatar Dec 06 '21 22:12 aklish

Also - is there an ID field in the Incident model?

aklish avatar Dec 06 '21 22:12 aklish