Skip to content

fix: explicit returns mixed with implicit (fall through) returns - #81

Merged
ethanyzhang merged 1 commit into
mainfrom
finding-autofix-58d5db4e
Mar 20, 2026
Merged

ethanyzhang merged 1 commit into
mainfrom
finding-autofix-58d5db4e

Conversation

@ethanyzhang

Copy link
Copy Markdown
Collaborator

In general, to fix mixed implicit/explicit returns, ensure every control path returns a value of the same type (or explicitly re-raises/propagates the error instead of returning). Here, execute_mysql_query explicitly returns the fetched rows on success but implicitly returns None on error. Without changing the external behavior too much, the cleanest approach is to make the except block explicitly return a safe, consistent value—an empty list—after logging the error. This preserves the current “log and swallow” error-handling style while avoiding the confusing None return.

Concretely, in benchmarks/scripts/mysql_utils.py, within execute_mysql_query, add a return [] statement inside the except Error as e: block, after the print(f"The error '{e}' occurred") line. No imports or additional helper methods are required. All changes are confined to the shown function; the rest of the file and other imports remain untouched.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@ethanyzhang ethanyzhang changed the title Fix for Explicit returns mixed with implicit (fall through) returns fix: explicit returns mixed with implicit (fall through) returns Mar 20, 2026
@ethanyzhang
ethanyzhang marked this pull request as ready for review March 20, 2026 21:35
@ethanyzhang
ethanyzhang merged commit a5ca816 into main Mar 20, 2026
14 of 16 checks passed
@ethanyzhang
ethanyzhang deleted the finding-autofix-58d5db4e branch March 20, 2026 21:43
ethanyzhang added a commit that referenced this pull request Apr 13, 2026
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant