vapor-community / node

A formatted data encapsulation meant to facilitate the transformation from one object to another
MIT License
25 stars 20 forks source link

ambiguous error #59

Open tanner0101 opened 7 years ago

tanner0101 commented 7 years ago

Code

try json.get("permissions") as [String]

Input

{
    "userId": "xxx"
}

Error

{
  "debugReason": "No value found at path '', expected 'String'",
  "error": true,
  "identifier": "Node.NodeError.unableToConvert",
  "possibleCauses": [
    "typo in key path",
    "underlying type is not convertible",
    "unexpected '.' being interpreted as path instead of key"
  ],
  "reason": "Internal Server Error",
  "suggestedFixes": [
    "called `get(...)` on a key or key path that does not exist in the data",
    "the data being parsed is missing required values or is incorrectly formatted",
    "found unconvertible data, e.g., got a string of letters when an integer is required",
    "if you have keys containing a '.' that shouldn't be interpreted as a path, use 'DotKey(\"actual.key\")'"
  ]
}
ThuggishNuggets commented 7 years ago

Yeah, I just lost an hour hunting down what was causing this problem. I had renamed a key on the server side, but forgot to update the parameter name in the Rested app. Sure wish this error gave you the specific key that caused the error.

tanner0101 commented 7 years ago

@ThuggishNuggets that's something we're working on in the next version. Updating this issue to reflect that.