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

Detailed logging of invalid requests #247

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

matthijskooijman
Copy link

Currently, some problems while parsing the payload generate fairly non-descript exceptions, where the message itself is not enough to diagnose the problem (see commit message for details). This PR ensures that on an InvalidRequestException, more details about the request and an exception backtrace is logged (see commit messages for details).

@matthijskooijman matthijskooijman changed the base branch from master to v2 January 25, 2024 20:11
@matthijskooijman
Copy link
Author

Note that identical code exists in sensorhub-service-sweapi. If this change is accepted, I'd be happy to apply the same changes there as well (though I do not have a setup ready to test them).

Previously, just the exception message was logged. For some exceptions,
this is quite non-descript, for example:

    2024-01-25 06:17:14.061 DEBUG [SWAPool-1] - Invalid request (BAD_PAYLOAD): Invalid payload: Invalid XML: Received event END_DOCUMENT, instead of START_ELEMENT or END_ELEMENT.

To solve this error, a backtrace is needed to figure out what was
expected exactly.

This particular exception message could probably be improved by itself,
but this commit solves this more generically, since there might be other
exceptions suffering from the same issue.

This commit changes the handling of InvalidRequestExceptions to use the
existing `logError()` function. This logs details of the request and
a backtrace. To ensure that this does not log "Internal server error"
but keep the existing "Invalid request", `logError()` is refactored to
accept an error prefix.
For some exceptions, the cause backtrace provides necessary details for
debugging the actual cause of the issue, since the message is not always
detailed enough.
@matthijskooijman matthijskooijman force-pushed the log-invalid-request-details branch 2 times, most recently from 6839697 to 5a70843 Compare February 1, 2024 16:54
@alexrobin alexrobin deleted the branch opensensorhub:master October 17, 2024 08:26
@alexrobin alexrobin closed this Oct 17, 2024
@alexrobin alexrobin reopened this Oct 17, 2024
@alexrobin alexrobin changed the base branch from v2 to master October 17, 2024 19:23
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 this pull request may close these issues.

2 participants