Skip to content

Fix IndentationError in validate_hostname function#362

Merged
abhimehro merged 2 commits intomainfrom
perf/fix-build-indentation-error-7c6ef10066515109
Feb 20, 2026
Merged

Fix IndentationError in validate_hostname function#362
abhimehro merged 2 commits intomainfrom
perf/fix-build-indentation-error-7c6ef10066515109

Conversation

@github-actions
Copy link

Problem

The build steps failed with an IndentationError when trying to import main.py:

File "/home/runner/work/ctrld-sync/ctrld-sync/main.py", line 943
    `@lru_cache`(maxsize=128)
IndentationError: expected an indented block after 'for' statement on line 940

This was caused by unreachable dead code in the validate_hostname function (lines 938-940) that appeared after a return statement in an exception handler.

Solution

Fixed by:

  • Removing the unreachable if not addr_info: and for res in addr_info: statements
  • Adding the missing return True statement after successful hostname validation

The function now correctly:

  1. Returns False on DNS resolution failure (line 936)
  2. Returns True after successful validation (new line 937)

Impact

  • ✅ Fixes critical build failure preventing Phase 3 performance work
  • ✅ No behavior change - the unreachable code was never executed
  • ✅ Restores ability to import main.py module

Testing

The fix restores the expected control flow:

  • Hostnames that fail DNS resolution → return False
  • Hostnames that resolve but have unsafe IPs → return False
  • Hostnames that pass all validation checks → return True

What Happens Next

Once this PR is merged:

  • The build steps will pass successfully
  • Phase 3 of the Daily Perf Improver workflow can proceed with actual performance improvements
  • The workflow can select and implement optimization goals from the research plan

AI generated by Daily Perf Improver

…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>
@trunk-io
Copy link

trunk-io bot commented Feb 19, 2026

😎 Merged manually by @abhimehro - details.

@abhimehro abhimehro marked this pull request as ready for review February 19, 2026 23:40
Copilot AI review requested due to automatic review settings February 19, 2026 23:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: and for res in addr_info: statements) that appeared after a return statement
  • Added the missing return True statement for the successful validation path

@github-actions
Copy link
Author

👋 Development Partner is reviewing this PR. Will provide feedback shortly.

@abhimehro abhimehro merged commit 6aafaab into main Feb 20, 2026
11 of 13 checks passed
@abhimehro abhimehro deleted the perf/fix-build-indentation-error-7c6ef10066515109 branch February 20, 2026 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants