Repository navigation
fix: include OCS error response bodies in logged errors - #255
Open
cestercian wants to merge 1 commit into
Open
cestercian wants to merge 1 commit into
cestercian wants to merge 1 commit into
Conversation
Signed-off-by: Cestercian <183791452+cestercian@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #254
str(NextcloudException)only gives the status and reason, so when e.g. scheduling the LLM task fails with a 412 the log never shows what the server actually said.This adds
format_exception()toex_app/lib/logger.py. It returns the usual traceback and then walks the cause/context chain, appendingOCS response for [status]: <body>for every NextcloudException that carries a response (capped at 2000 chars). The walk matters because nc_model.py re-raises some of these asException(...) from e.AsyncNextcloudAppgives you niquestsAsyncResponses, where.textis a coroutine, so the helper is async and awaits it (it also handles the syncResponsestr). If reading the body fails, it just falls back to the plain traceback.The error logs in
main.py(fetching the next task, streaming, task failure, reporting) now use it. Those go to stdout and to the Nextcloud log throughlog().There is no test suite in the repo, so I checked it locally against nc-py-api 0.30.3 with a small script covering sync and async responses, a wrapped exception, a response whose body cannot be read, and a non-Nextcloud exception. I ran it with
-W errorso an un-awaited coroutine would fail it.