Skip to content

Fix failed batch operations printing result and passing silently - #361

Merged
iLLiCiTiT merged 2 commits into
developfrom
bugfix/failed-operations-reporting
Sep 14, 2026
Merged

Fix failed batch operations printing result and passing silently#361
iLLiCiTiT merged 2 commits into
developfrom
bugfix/failed-operations-reporting

Conversation

@BigRoy

@BigRoy BigRoy commented Sep 12, 2026

Copy link
Copy Markdown
Member

Bug

When a batch of operations fails (send_batch_operations, send_background_batch_operations(wait=True), OperationsSession.commit()):

  1. The whole result is printed to stdout — noise in host application consoles and pipelines, not controllable by logging.
  2. If the server reports success: false but no individual operation as failed, the method returns without raising, so the failure is silently ignored.
  3. Missing operations key or an operation id not found in the sent operations raise KeyError / StopIteration instead of FailedOperations.

Fix

  • Replace print with a warning log.
  • Raise FailedOperations with the server response when no failed operation can be identified.
  • Use .get("operations") and fall back to the operation result when the sent operation is not found.

Reproduce

Updating a non-existing folder (does not change any data):

import ayon_api
con = ayon_api.get_server_api_connection()
con.send_batch_operations("<project>", [{
    "type": "update",
    "entityType": "folder",
    "entityId": "0" * 32,
    "data": {"label": "x"},
}])
# develop: the result dict is printed to stdout, then FailedOperations is raised
# this PR: result is logged as a warning, FailedOperations is raised

Testing notes

  • Snippet above, check the output goes through logging (e.g. silence it with logging.getLogger(con.log.name).setLevel(logging.ERROR)).
  • tests/test_operations_result.py covers the silent failure case.

🤖 Generated with Claude Code

- '_validate_operations_result' printed the whole result to stdout.
  It is logged as warning instead.
- When the batch failed but no single operation was reported as failed,
  the method returned without raising, so the failure was ignored.
- Missing 'operations' key or an unknown operation id raised KeyError or
  StopIteration instead of FailedOperations.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment thread tests/test_operations_result.py
@BigRoy
BigRoy marked this pull request as ready for review September 14, 2026 15:12
@BigRoy BigRoy self-assigned this Sep 14, 2026
@BigRoy BigRoy added the type: bug Something isn't working label Sep 14, 2026
@iLLiCiTiT
iLLiCiTiT merged commit 0ef3bc0 into develop Sep 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants