Potential fix for code scanning alert no. 2: Variable defined multiple times#69
Merged
zliang-akamai merged 1 commit intomainfrom Feb 4, 2026
Merged
Potential fix for code scanning alert no. 2: Variable defined multiple times#69zliang-akamai merged 1 commit intomainfrom
zliang-akamai merged 1 commit intomainfrom
Conversation
…e times Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
lgarber-akamai
approved these changes
Feb 3, 2026
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.
Potential fix for https://github.com/linode/py-metadata/security/code-scanning/2
In general, when a variable or function is defined multiple times without the earlier definition being used, you should either remove the earlier definition or rename one of them so all intended code paths are reachable. For pytest tests, having two functions with the same name in the same module means only the second definition is discoverable and runnable; the first is effectively lost.
Here, the best fix without changing existing functionality is to give the synchronous and asynchronous tests distinct names, so both can run. We keep the bodies exactly the same and only adjust the first function name to something unique, e.g.,
test_get_ssh_keys_sync. This preserves the synchronous test, preserves the async test and its marker, and resolves the CodeQL complaint that the first assignment totest_get_ssh_keysis unnecessary.Concretely, in
test/integration/test_ssh.py, change line 8 fromdef test_get_ssh_keys(client: MetadataClient):todef test_get_ssh_keys_sync(client: MetadataClient):. No imports, methods, or other definitions are needed beyond this rename.Suggested fixes powered by Copilot Autofix. Review carefully before merging.