Skip to content

IPv6 node addresses produce an invalid request URL #154

Closed

Description

@RaphaelFakhri

A node with an IPv6 address can't be reached. Node.url() joins the host and port as {host}:{port} without enclosing an IPv6 literal in brackets, so every request fails with httpx.InvalidURL before it is sent.

Both ways of configuring a node are affected:

  • A URL string such as "http://[::1]:8108". Node.from_url takes the host from urlparse(url).hostname, which strips the brackets, so the host is stored as ::1.
  • A node dict such as {"host": "::1", "port": 8108, "protocol": "http"}.

Steps to reproduce

import typesense

client = typesense.Client({
    "api_key": "xyz",
    "nodes": ["http://[::1]:8108"],
    "num_retries": 0,
})
print(client.api_call.node_manager.nodes[0].url())
client.operations.is_healthy()

Actual behavior

http://::1:8108
httpx.InvalidURL: Invalid port: ':1:8108'

Expected behavior

The client sends requests to http://[::1]:8108.

Environment

  • typesense-python: master (8727d2b)
  • httpx 0.28.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions