Skip to content

bug: fix check for server ready when using 0.0.0.0 as host#9002

Merged
ogabrielluiz merged 4 commits into
mainfrom
fix-server-ready-check
Jul 11, 2025
Merged

bug: fix check for server ready when using 0.0.0.0 as host#9002
ogabrielluiz merged 4 commits into
mainfrom
fix-server-ready-check

Conversation

@jordanrfrazier
Copy link
Copy Markdown
Collaborator

@jordanrfrazier jordanrfrazier commented Jul 11, 2025

Fixes server ready check so that wait_for_server_ready completes successfully.

Summary by CodeRabbit

  • Bug Fixes
    • Improved server health check reliability when the server is started with the host set to "0.0.0.0". The health check now correctly targets "localhost", ensuring accurate server readiness detection.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 11, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The wait_for_server_ready function in src/backend/base/langflow/__main__.py was updated to replace the host "0.0.0.0" with "localhost" when constructing the health check URL and determining TLS verification. No public API or function signatures were changed.

Changes

File(s) Change Summary
src/backend/base/langflow/main.py Modified health check logic to substitute "0.0.0.0" with "localhost" in URL and TLS verification.

Suggested labels

size:M, lgtm

Suggested reviewers

  • mfortman11
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-server-ready-check

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jul 11, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/backend/base/langflow/__main__.py (1)

154-165: Add an explicit timeout or max-retry cap to avoid infinite waits.

wait_for_server_ready will currently loop forever if the child process never binds (e.g. mis-config, crash-on-start).
Consider accepting a max_retries or timeout parameter (there is already a CLI option) and raise a clear, actionable exception once exceeded.

🧹 Nitpick comments (1)
src/backend/base/langflow/__main__.py (1)

157-159: Leverage is_loopback_address() for TLS verification instead of a hard-coded tuple.

Using the helper makes the intent clearer and automatically includes future loopback variants (e.g. ::1).

-                f"{protocol}://{health_check_host}:{port}/health", 
-                verify=health_check_host not in ("127.0.0.1", "localhost")
+                f"{protocol}://{health_check_host}:{port}/health",
+                # Skip TLS verification for any loopback address
+                verify=not is_loopback_address(health_check_host)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c38df91 and 1d937ad.

📒 Files selected for processing (1)
  • src/backend/base/langflow/__main__.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`src/backend/**/*.py`: Run make format_backend to format Python code early and often Run make lint to check for linting issues in backend Python code

src/backend/**/*.py: Run make format_backend to format Python code early and often
Run make lint to check for linting issues in backend Python code

📄 Source: CodeRabbit Inference Engine (.cursor/rules/backend_development.mdc)

List of files the instruction was applied to:

  • src/backend/base/langflow/__main__.py
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test Langflow's REST API endpoints using the async 'client' fixture and assert correct status codes and response structure.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to src/backend/tests/**/*.py : Use the 'client' fixture (an async httpx.AsyncClient) for API tests, as defined in 'src/backend/tests/conftest.py'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
src/backend/base/langflow/__main__.py (1)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Ruff Style Check (3.13)
  • GitHub Check: Update Starter Projects
  • GitHub Check: Run Ruff Check and Format

Comment thread src/backend/base/langflow/__main__.py Outdated
Comment on lines +150 to +152
# Use localhost for health check when host is 0.0.0.0 (bind to all interfaces)
health_check_host = "localhost" if host == "0.0.0.0" else host

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Cover the IPv6 wildcard (::) as well, not just 0.0.0.0.

The server can also be started with the IPv6 “bind-all” address ::.
Without handling this case the readiness probe still fails for IPv6-only environments (e.g. Docker on Mac when IPv4 is disabled).

-    # Use localhost for health check when host is 0.0.0.0 (bind to all interfaces)
-    health_check_host = "localhost" if host == "0.0.0.0" else host
+    # Use localhost for health check when host is an unspecified/bind-all address
+    # – covers both IPv4 (0.0.0.0) and IPv6 (::)
+    health_check_host = "localhost" if host in ("0.0.0.0", "::") else host
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Use localhost for health check when host is 0.0.0.0 (bind to all interfaces)
health_check_host = "localhost" if host == "0.0.0.0" else host
# Use localhost for health check when host is an unspecified/bind-all address
# – covers both IPv4 (0.0.0.0) and IPv6 (::)
health_check_host = "localhost" if host in ("0.0.0.0", "::") else host
🤖 Prompt for AI Agents
In src/backend/base/langflow/__main__.py around lines 150 to 152, the health
check host assignment only checks for the IPv4 wildcard address "0.0.0.0" but
does not handle the IPv6 wildcard "::". Update the condition to also check if
the host is "::" and in that case set health_check_host to "localhost" to ensure
the readiness probe works correctly in IPv6-only environments.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 11, 2025
@ogabrielluiz ogabrielluiz enabled auto-merge July 11, 2025 12:51
@ogabrielluiz ogabrielluiz added this pull request to the merge queue Jul 11, 2025
Merged via the queue into main with commit 7a02842 Jul 11, 2025
76 of 77 checks passed
@ogabrielluiz ogabrielluiz deleted the fix-server-ready-check branch July 11, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants