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

Error objects don't log well #720

Closed
josephjclark opened this issue Jun 24, 2024 · 2 comments · Fixed by #728
Closed

Error objects don't log well #720

josephjclark opened this issue Jun 24, 2024 · 2 comments · Fixed by #728
Assignees

Comments

@josephjclark
Copy link
Collaborator

josephjclark commented Jun 24, 2024

A few adaptors have a pattern where they create an Error object and throw it.

image

This isn't itself unreasonable!

But when serializing that error for the console or the final state, we lose all the detail.

If I console.log this error, I do see some of the properties:
image

Here you can see my custom status code.

The stack trace right now is not useful - although will be once we handle source mapping

The thing we report in the CLI isn't so good:

image

And the thing we write to state is useless:

image

No surprises here, it's just getting a better understanding of how different errors are reported out of the runtime

@josephjclark
Copy link
Collaborator Author

Probably the code that generates that error object on state should serialize all the keys of the error object into JSON.

And the Runtime log at the end, which says check state for details, should pretty-print the keys nicely too

@josephjclark
Copy link
Collaborator Author

Maybe related? Posting here

In okd, using http helpers without much wrapping, I see this in my logs:

image

Ok, it reported a 404, but there's more data in the error response.

State doesn't show anything useful:

{
  "data": {},
  "errors": {
    "job-1": {
      "type": "AdaptorError",
      "stepId": "job-1",
      "message": "GET to https://sandbox.getodk.cloud/v1/projects/69 returned 404: Not Found",
      "error": {
        "source": "runtime",
        "type": "AdaptorError",
        "name": "AdaptorError",
        "severity": "fail",
        "message": "GET to https://sandbox.getodk.cloud/v1/projects/69 returned 404: Not Found"
      }
    }
  }
}

But the actual Error object that was reported is super rich! This should serialize better!

image

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

Successfully merging a pull request may close this issue.

1 participant