Fix IndentationError in validate_hostname function#362
Merged
Conversation
…tname The validate_hostname function had unreachable dead code (lines 938-940) after a return statement in the exception handler. This caused an IndentationError when Python tried to parse the module. Fixed by: - Removing the unreachable if/for block - Adding missing return True statement after successful validation loop This fixes the build failure shown in build-steps.log where main.py could not be imported. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
😎 Merged manually by @abhimehro - details. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical IndentationError that prevented the main.py module from being imported. The error was caused by unreachable dead code (lines 938-940) that appeared after a return False statement within the exception handler of the validate_hostname function.
Changes:
- Removed unreachable code (
if not addr_info:andfor res in addr_info:statements) that appeared after a return statement - Added the missing
return Truestatement for the successful validation path
Author
|
👋 Development Partner is reviewing this PR. Will provide feedback shortly. |
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.
Problem
The build steps failed with an IndentationError when trying to import
main.py:This was caused by unreachable dead code in the
validate_hostnamefunction (lines 938-940) that appeared after a return statement in an exception handler.Solution
Fixed by:
if not addr_info:andfor res in addr_info:statementsreturn Truestatement after successful hostname validationThe function now correctly:
Falseon DNS resolution failure (line 936)Trueafter successful validation (new line 937)Impact
main.pymoduleTesting
The fix restores the expected control flow:
What Happens Next
Once this PR is merged: