Skip to content

fix: guard against None rowcount in workflow bulk-delete methods#37678

Open
lavkeshdwivedi wants to merge 2 commits into
langgenius:mainfrom
lavkeshdwivedi:fix/workflow-delete-rowcount-none-37643
Open

fix: guard against None rowcount in workflow bulk-delete methods#37678
lavkeshdwivedi wants to merge 2 commits into
langgenius:mainfrom
lavkeshdwivedi:fix/workflow-delete-rowcount-none-37643

Conversation

@lavkeshdwivedi

Copy link
Copy Markdown

Summary

Fixes #37643

Five bulk-delete methods in the workflow repositories used result.rowcount directly in += or as a return value. CursorResult.rowcount is documented to return None for some DBAPI drivers/operations, which crashes these methods with:

TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

Affected methods

sqlalchemy_api_workflow_node_execution_repository.py

  • delete_expired_executions
  • delete_executions_by_app
  • delete_executions_by_ids

sqlalchemy_api_workflow_run_repository.py

  • delete_runs_by_ids
  • delete_runs_by_app

Fix

Apply result.rowcount or 0 — the same pattern already used correctly in sibling methods delete_by_runs and count_by_runs in the same files.

Test plan

  • Verify delete_expired_executions, delete_executions_by_app, delete_executions_by_ids return 0 (not raise) when driver returns rowcount=None
  • Verify delete_runs_by_ids, delete_runs_by_app return 0 (not raise) when driver returns rowcount=None
  • Existing integration tests in test_sqlalchemy_api_workflow_node_execution_repository.py and test_sqlalchemy_api_workflow_run_repository.py still pass

🤖 Generated with Claude Code

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 20, 2026
SQLAlchemy's CursorResult.rowcount can return None for some DBAPI
drivers/operations. Five bulk-delete methods used result.rowcount
directly in += or as a return value, causing:

  TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

Apply the `result.rowcount or 0` pattern already used in sibling
methods (delete_by_runs, count_by_runs) across all five affected sites:

- sqlalchemy_api_workflow_node_execution_repository.py
  - delete_expired_executions
  - delete_executions_by_app
  - delete_executions_by_ids
- sqlalchemy_api_workflow_run_repository.py
  - delete_runs_by_ids
  - delete_runs_by_app

Fixes langgenius#37643
Covers all five affected methods to guard against regression:
- delete_expired_executions, delete_executions_by_app,
  delete_executions_by_ids (node execution repository)
- delete_runs_by_ids, delete_runs_by_app (run repository)

Each test mocks the DBAPI session to return rowcount=None and asserts
the method returns 0 instead of raising TypeError.
@lavkeshdwivedi lavkeshdwivedi force-pushed the fix/workflow-delete-rowcount-none-37643 branch from 0358db1 to d3da146 Compare June 20, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: five workflow deletion methods crash with TypeError when CursorResult.rowcount is None

1 participant