fix: guard against None rowcount in workflow bulk-delete methods#37678
Open
lavkeshdwivedi wants to merge 2 commits into
Open
fix: guard against None rowcount in workflow bulk-delete methods#37678lavkeshdwivedi wants to merge 2 commits into
lavkeshdwivedi wants to merge 2 commits into
Conversation
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.
0358db1 to
d3da146
Compare
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.
Summary
Fixes #37643
Five bulk-delete methods in the workflow repositories used
result.rowcountdirectly in+=or as a return value.CursorResult.rowcountis documented to returnNonefor some DBAPI drivers/operations, which crashes these methods with:Affected methods
sqlalchemy_api_workflow_node_execution_repository.pydelete_expired_executionsdelete_executions_by_appdelete_executions_by_idssqlalchemy_api_workflow_run_repository.pydelete_runs_by_idsdelete_runs_by_appFix
Apply
result.rowcount or 0— the same pattern already used correctly in sibling methodsdelete_by_runsandcount_by_runsin the same files.Test plan
delete_expired_executions,delete_executions_by_app,delete_executions_by_idsreturn 0 (not raise) when driver returnsrowcount=Nonedelete_runs_by_ids,delete_runs_by_appreturn 0 (not raise) when driver returnsrowcount=Nonetest_sqlalchemy_api_workflow_node_execution_repository.pyandtest_sqlalchemy_api_workflow_run_repository.pystill pass🤖 Generated with Claude Code