Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions nc_py_api/ex_app/providers/task_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,24 @@ def report_result(
task_id: int,
output: dict[str, typing.Any] | None = None,
error_message: str | None = None,
user_facing_error_message: str | None = None,
) -> dict[str, typing.Any]:
"""Report result of the task processing to Nextcloud."""
"""Report result of the task processing to Nextcloud.

:param error_message: Technical/debug message for administrators.
:param user_facing_error_message: Message shown to the end user when the task failed.
Available starting with Nextcloud 33.
"""
with contextlib.suppress(NextcloudException):
if r := self._session.ocs(
"POST",
f"/ocs/v2.php/taskprocessing/tasks_provider/{task_id}/result",
json={"taskId": task_id, "output": output, "errorMessage": error_message},
json={
"taskId": task_id,
"output": output,
"errorMessage": error_message,
"userFacingErrorMessage": user_facing_error_message,
},
Comment on lines +189 to +206

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add coverage for the new payload field in both APIs.

The supplied sync and async tests only pass error_message; they do not verify that user_facing_error_message is serialized as userFacingErrorMessage. Add focused tests for both methods.

Also applies to: 292-304

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nc_py_api/ex_app/providers/task_processing.py` around lines 189 - 201, Extend
the sync and async task-result API tests for their respective result-reporting
methods to pass user_facing_error_message and assert the request payload
contains it serialized as userFacingErrorMessage. Keep the existing
error_message assertions and cover both APIs with focused payload checks.

):
return r
return {}
Expand Down Expand Up @@ -283,13 +294,24 @@ async def report_result(
task_id: int,
output: dict[str, typing.Any] | None = None,
error_message: str | None = None,
user_facing_error_message: str | None = None,
) -> dict[str, typing.Any]:
"""Report result of the task processing to Nextcloud."""
"""Report result of the task processing to Nextcloud.

:param error_message: Technical/debug message for administrators.
:param user_facing_error_message: Message shown to the end user when the task failed.
Available starting with Nextcloud 33.
"""
with contextlib.suppress(NextcloudException):
if r := await self._session.ocs(
"POST",
f"/ocs/v2.php/taskprocessing/tasks_provider/{task_id}/result",
json={"taskId": task_id, "output": output, "errorMessage": error_message},
json={
"taskId": task_id,
"output": output,
"errorMessage": error_message,
"userFacingErrorMessage": user_facing_error_message,
},
):
return r
return {}
Loading