Skip to content

fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111

Closed

Description

@dan-petty

Problem

Lines cited at dcafadf. Paths are under src/devops_cli/ unless they start with tests/. Every httpx2, urllib.parse and kubernetes-client behaviour below was confirmed by offline probes (no network, no DNS, no cluster) against httpx2 2.13.0 and kubernetes 36.0.3, the exact pins at pyproject.toml:19 and :23. The rest comes from reading the code at that commit.

Service, node and API-proxy URLs are assembled with f-strings and scheme://netloc splicing. httpx2 is already the transport for all of them, and its httpx2.URL builder handles every case below.

Confirmed defects:

  • IPv6 addresses produce URLs nothing can parse. f"http://{host}:{port}" with an IPv6 node or LoadBalancer address gives http://2001:db8::1:30080. urllib.parse raises ValueError: Port could not be cast to integer value on it, and httpx2.URL raises InvalidURL: Invalid port. httpx2.URL(scheme="http", host="2001:db8::1", port=30080) gives http://[2001:db8::1]:30080. The sites:
    • commands/k8s/networking.py:122 (node address from kubectl get nodes), :165 (LoadBalancer ingress) and :411-412 (OTel endpoint derived from the Jaeger host);
    • k8s/service.py:327 and :334 (the same two lookups through the Kubernetes client);
    • telemetry/collector.py:25, whose host comes from cluster_host (k8s/node_port.py:66-74), which strips the brackets through urlparse().hostname;
    • sandbox/probe.py:515 and :527 (HTTP and OpenAPI probe URLs).
  • configure-urls fails on an IPv6 cluster. Both stacks pass the detected URLs to _resolve_accessible_url: the infra stack (_configure_infra_stack_urls, networking.py:366-390) and the LLM stack (_configure_llm_stack_urls, :447-470). When nothing answers on the preferred localhost ports, _resolve_accessible_url("http://2001:db8::1:30080") raises ValueError at networking.py:360 (parsed.port). Nothing on the path from configure_urls (:861) through _dispatch_nodeport_urls (:820-830) catches it.
  • Dot segments and unchecked fields leave the Service proxy and carry the kubeconfig credential.
    • ServiceRef.proxy_path (k8s/service_proxy.py:73-87) and resolve_proxy_target (:246-258) append the caller's path to /api/v1/namespaces/{namespace}/services/{target}/proxy with no check. Namespace, service and port go into that template unchecked as well.
    • httpx2 removes dot segments (RFC 3986 section 5.2.4) when it parses the URL it sends. So devops k8s service-url prometheus -n monitoring --port 9090 --path ../../../secrets/foo --fetch sends /api/v1/namespaces/monitoring/secrets/foo, which is the Secret read endpoint, not the Service. get_json (k8s/service_http.py:47-58) sends it with the kubeconfig's credentials (its bearer token or client certificate, service_proxy.py:202-234) and prints the reply (commands/k8s/networking.py:1226-1235).
    • --port is free text. --port '9090/../../secrets/foo?' sends /api/v1/namespaces/monitoring/secrets/foo with /proxy as the query, and --port '9090?' moves /proxy into the query (both measured).
    • Namespace and service: ServiceRef(namespace="..", service="..", port="80") resolves to /api/v1/services/..:80/proxy.
    • Configured values: parse_service_url (service_proxy.py:102-138) keeps .. segments, so k8s://monitoring/prometheus:9090/../../../secrets/foo parses with path ../../../secrets/foo. Today's callers of configured values replace that path. The dashboard passes api/v1/label/__name__/values (ui/data_providers.py:455-460), and Qdrant goes through resolve_proxy_connection, which passes path="" (service_proxy.py:295). So a configured path is sent only by get_json(url) with no path, and today only the CLI's --fetch calls that (networking.py:1227). A configured namespace is used by every caller.
    • A k8s:// address names a Service. It must not reach any other API path.
  • An https:// probe target is probed over http. _parse_target_endpoint (sandbox/probe.py:485-495) drops the scheme, and endpoints travel as (host, port) tuples (:399, :403-404, :455-466). So https://example.com:8443 is probed at http://example.com:8443/healthz. fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112 makes that function return an httpx2.Origin, scheme included, and carries origins to the loop at :455, which still passes only host and port to _dispatch_probes_for_port. This item passes the origin on and builds the probe URLs from it, because it rewrites the lines that build them.
  • Other string-built URLs of the same kind:
    • networking.py:679 builds f"https://{chosen}" from an Ingress host.
    • networking.py:570 re-renders the k8s:// form that ServiceRef.describe() (service_proxy.py:89-94) already renders.
    • networking.py:1029 prints http://{address}:{lport}, which reads http://::1:8080 for --address ::1. kubectl's --address takes a comma-separated list, so --address localhost,::1 prints http://localhost,::1:8080. The print runs after subprocess.Popen (:1011) and before daemon_mgr.save_forwards (:1030). If it raised, the detached port-forward would keep running with nothing recording it. A literal httpx2.URL(scheme="http", host="localhost,::1", port=8080) raises InvalidURL (measured).
    • service_proxy.py:291-302 and service_http.py:28-35 splice f"{parsed.scheme}://{parsed.netloc}". This is cleanup, not a leak: kubeconfig server URLs carry no userinfo, and these strings only become in-memory pool keys (http/pool.py:61-76) that are never logged.
    • service_http.py:62 joins a direct URL and a path with rstrip("/") and lstrip("/").

Replacement: build with httpx2.URL(scheme=..., host=..., port=...). It brackets IPv6, including ::ffff:192.0.2.1 and fe80::1%eth0, and both urllib.parse.urlsplit and httpx2.URL parse the result back to the same host and port. Each rule below comes from a measured httpx2 behaviour. Skipping one causes a regression.

  • Default ports. httpx2 drops them: port=80 gives http://192.0.2.10, and .port is None. The loopback fallback at networking.py:358-361 tests if parsed.port:, so a port-80 LoadBalancer would lose the fallback it gets today (http://localhost:80). Read the port with httpx2.URL(url).origin.port, which fills in the scheme's default.
  • Empty hosts. host="" builds http://:30080 without an error. Keep the existing if node_ip, if lb_host and addr.address guards.
  • OTel endpoint. Build a fresh httpx2.URL(scheme="http", host=httpx2.URL(jaeger_url).host, port=CONST_OTEL_OTLP_HTTP_PORT) (config/constants.py:989). Do not use copy_with, which keeps the query and userinfo: copy_with(port=4318, path="/") on http://example.com:16686/search?x=1 gives http://example.com:4318/?x=1. This also removes the literal 4318 at networking.py:412.
  • Appending a path. One function, append_path(base, reference), does every append in this item: proxy_path (on the scheme-less template path), resolve_proxy_target, describe(), get_json's direct branch (service_http.py:62) and the probe's HTTP paths. It returns an httpx2.URL and works like this:
    • An empty reference returns the base unchanged, so the Service root stays .../proxy with no trailing / (pinned at tests/test_k8s_service_proxy.py:86-90).
    • The base's path is made to end in / through copy_with(raw_path=...). Do not use copy_with(path=...), which takes the decoded path: on https://example.com/a%2Fb it gives https://example.com/a/b/.
    • The reference loses its leading / and gets ./ in front, the form RFC 3986 section 4.2 prescribes for a relative path, and is then passed to base.join(...).
    • Without that step, join misreads three kinds of reference (all measured). /api/v1/x counts as an absolute path, so on https://example.com/k8s/clusters/c-1/ it gives https://example.com/api/v1/x. foo:bar counts as a URI with scheme foo. //other.example.com/x counts as another host.
    • With it, foo:bar gives /foo:bar and //other.example.com/x gives /other.example.com/x on the same host, as today's f-strings do. On .../k8s/clusters/c-1/, ./api/v1/namespaces/ns/services/svc:80/proxy/a%2Fb?x=1 keeps the prefix, the %2F and the query.
    • Why a function and not a library call: httpx2.URL.join and urllib.parse.urljoin resolve a reference (RFC 3986 section 5.2), and neither has an "append this path" call. httpx2's own append, the base_url merge of httpx2.Client (trailing / on the base, leading / dropped from the reference), is private to the client. yarl's / operator appends, but yarl is only a transitive dependency (1.24.5, through aiohttp), and fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112 rules out a second URL parser. The function is built only from httpx2 calls; it parses nothing itself.
    • The kubernetes client keeps the server's path the same way (url = self.configuration.host + resource_path in its ApiClient).
  • Encoding. Do not quote the reference. urllib.parse.quote(seg, safe="") turns a%2Fb into a%252Fb and https:prom:9090 into https%3Aprom%3A9090. httpx2 leaves a%2Fb as is.
  • Dot segments. A path is refused when httpx2 would rewrite it. The test is httpx2's own normalisation, the code that causes the escape, not a segment parser:
    • httpx2 keeps dot segments in a scheme-less httpx2.URL(path=...) and removes them (RFC 3986 section 5.2.4) once copy_with(scheme=..., host=...) makes the URL absolute. A path whose raw_path differs between the two is refused. Measured: /a/../b becomes /b.
    • The test reads the path part of the reference, without its leading / and without its query. It runs on the percent-decoded path re-encoded with urllib.parse.quote(urllib.parse.unquote(path), safe="/"), so %2e%2e reads as ... httpx2 sends %2e%2e unchanged, and how the API server treats it was not measured. The re-encoded copy is only tested, never sent.
    • Measured with that test: ../../../secrets/foo, /../grafana:80/api/health, a/../b, ., ./x, %2e%2e/x, .%2e/x and %2E/x are refused; a%2Fb, foo:bar, .hidden, a..b, ..., x//y, a%3Fb, ü and api/v1/label/__name__/values pass.
    • It runs wherever a path enters the proxy: when a ServiceRef is built (below), on a proxy_path override, and on get_json's path (direct and k8s:// alike). It is refused with ServiceAddressError.
    • The probe's --path is not tested: it carries no credential, and httpx2 already normalises it today.
  • ServiceRef checks itself when it is built. Its __post_init__ raises ServiceAddressError if a field is bad:
    • namespace, service or port fails validate_k8s_identifier(..., namespace=True) (core/validation.py:450). That is the RFC 1123 label rule (CONST_K8S_LABEL_RE, config/constants.py:564). It accepts a port number and a port name such as http-query, and refuses ?, #, /, . and :. Re-raise its ValidationError as ServiceAddressError.
    • path fails the dot-segment test.
    • This must happen at construction, not only on append, because --fetch sends ref.describe() (networking.py:1227), and httpx2's builder removes dot segments. Built with httpx2, describe() of path /prometheus:9090/../grafana:80/api/health renders k8s://monitoring/grafana:80/api/health (measured), so --path ../grafana:80/api/health --fetch would silently fetch from Grafana. Once the constructor refuses such a ref, no describe() ever renders a rewritten address.
  • Where ServiceAddressError must be caught. It is caught today at networking.py:1206 and :1228 and at service_http.py:76.
    • service_url builds its ServiceRef at networking.py:1193, outside both try blocks. Wrap that build too, with exit_on_error(ServiceAddressError) from core/cli.py:187-200, which prints the message and exits with the error's code.
    • That catch is needed because the command is registered bare (app.command("service-url")(service_url), commands/k8s/__init__.py:109). main.py runs commands with standalone_mode=False (:144-148) and catches only click.ClickException (:169) and SystemExit (:185). An uncaught ServiceAddressError therefore ends in a traceback.
    • The other constructors need no change. parse_service_url (service_proxy.py:131) already raises ServiceAddressError to its callers. discover_service (:342) takes its names from the API server, and they already meet the rule.
  • describe(). Append path with append_path to the scheme-less httpx2.URL(path="/<service>:<port>"), then call copy_with(scheme=..., host=namespace). Pass query= only when query is non-empty, because query=b"" emits a trailing ?. Measured: this renders k8s+https://argocd/argocd-server:443/api/v1/session?a=1.
    • Do not join onto a k8s:// base. For a scheme it does not know, httpx2's join returns the reference unchanged: on k8s+https://argocd/argocd-server:443/, join("./api/v1/session") gives ./api/v1/session (measured). append_path therefore takes an http(s) base or a scheme-less one.
    • networking.py:570 builds a ServiceRef and calls describe() instead of keeping its own f-string.
    • Every entry in _PROXY_TARGETS_INFRA and _PROXY_TARGETS_LLM (:497-507) carries a numeric port hint. The <port> fallback at :569 is therefore never used, and the port check would refuse it, so it goes.
  • Pool keys and the Qdrant split.
    • _transport_key builds its key from httpx2.URL(url).origin (scheme, host, port), which drops userinfo, lowercases the host and fills in the default port.
    • resolve_proxy_connection builds base_url fresh from that origin's scheme, host and port. It takes prefix from the raw path, urllib.parse.urlsplit(str(url)).path, as today's urlparse does, and not from httpx2's .path, which percent-decodes: /a%2Fb%20c reads as /a/b c.
    • The fresh base carries no path, which qdrant-client 1.19.1 requires when a prefix is given (qdrant_remote.py:109-112). A default port dropped from it is fine: with no port, the client addresses the host alone (:209).
  • Probe scheme. fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112 returns every probe endpoint as an httpx2.Origin: a target with its own scheme, a bare host:port with scheme http, and a sandbox instance's port bindings (:399) with scheme http.
    • _dispatch_probes_for_port takes that origin in place of host and port, and the loop at :455 passes it.
    • The HTTP and OpenAPI probes build their base with httpx2.URL(scheme=..., host=origin.host, port=origin.port). The scheme is https when the origin's is https, and http otherwise, so a grpc:// target keeps its HTTP probes over http as today.
    • The TCP and gRPC probes take origin.host and origin.port.
  • Port-forward message. Build httpx2.URL(scheme="http", host=address, port=lport) from --address as given.
    • A value httpx2 refuses with httpx2.InvalidURL is printed as written, next to the local port, so the message never raises. That covers kubectl's comma-separated list: localhost,::1 raises InvalidURL (measured). No list parsing is added.
    • The URL text is built before Popen, so nothing between starting the process and save_forwards can raise. The pid is added after.

Out of scope:

Acceptance criteria

  • An offline table test covers the builders, one row per site:
    • a node address 2001:db8::1 with NodePort 30080 gives http://[2001:db8::1]:30080 (networking.py:122, k8s/service.py:334);
    • a LoadBalancer ingress IP 2001:db8::1 on port 9090 gives http://[2001:db8::1]:9090 (networking.py:165, k8s/service.py:327);
    • an API server https://[2001:db8::1]:6443 gives a collector endpoint http://[2001:db8::1]:<nodePort>;
    • a Jaeger URL http://u:pw@[2001:db8::2]:16686/?x=1 gives otel.endpoint http://[2001:db8::2]:4318, with no userinfo, path or query;
    • ::ffff:192.0.2.1 and fe80::1%eth0 come out bracketed and parse back with urlsplit and httpx2.URL to the same host and port;
    • a probe of 2001:db8::1 on port 8080 with path health builds http://[2001:db8::1]:8080/health, and its OpenAPI base is http://[2001:db8::1]:8080;
    • the proxy-mode dry-run preview equals ServiceRef(...).describe() for every key.
  • Port-forward message, with subprocess.Popen and the daemon manager mocked:
    • --address ::1 prints http://[::1]:<port>;
    • --address 0.0.0.0 prints http://0.0.0.0:<port>;
    • --address localhost,::1 prints localhost,::1 as written with the port, raises nothing, and save_forwards records every forward started.
  • configure-urls on an IPv6 cluster. The Kubernetes lookups are mocked to return a NodePort Service and a node whose InternalIP is 2001:db8::1. Today both rows below raise ValueError at networking.py:360.
    • With socket.create_connection patched so that connections to 2001:db8::1 succeed and connections to localhost and 127.0.0.1 fail, _configure_infra_stack_urls and _configure_llm_stack_urls raise nothing. They write bracketed URLs: http://[2001:db8::1]:<nodePort> for each detected service, and otel.endpoint http://[2001:db8::1]:4318. valkey.host is fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113's and is not asserted.
    • With every connection refused, both raise nothing and write the loopback fallback http://localhost:<nodePort>.
  • A LoadBalancer on port 80 whose address is unreachable still gets the loopback fallback http://localhost:80.
  • Proxy URLs:
    • With kubeconfig server https://example.com/k8s/clusters/c-1, resolve_proxy_target keeps /k8s/clusters/c-1 before /api/v1/namespaces/monitoring/services/prometheus:9090/proxy/.... resolve_proxy_connection gives base https://example.com and a prefix starting k8s/clusters/c-1/api/v1/. A %2F in the server's path reaches the prefix unchanged.
    • A suffix a%2Fb stays a%2Fb, and the TLS target stays https:argocd-server:443. Suffixes foo:bar, .hidden and a..b pass the dot-segment test and are sent on the Service's proxy path.
    • These are refused with ServiceAddressError before any request, and a fake transport records no request:
      • service-url prometheus -n monitoring --port 9090 --path ../../../secrets/foo, with and without --fetch;
      • service-url prometheus -n monitoring --port 9090 --path ../grafana:80/api/health --fetch;
      • --port '9090/../../secrets/foo?' and --port '9090?';
      • the configured k8s://monitoring/prometheus:9090/../../../secrets/foo;
      • a get_json path containing .., . or %2e%2e, for a k8s:// URL and for a direct URL;
      • namespace or service ...
    • ServiceRef(namespace="monitoring", service="prometheus", port="9090", path="../grafana:80/api/health") raises ServiceAddressError. No describe() call can return a rewritten address.
    • devops k8s service-url .. -n .. prints the error and exits 1 with no traceback: under CliRunner, the exit code is 1 and result.exception is a SystemExit.
    • describe() without a query has no trailing ?.
    • _transport_key gives one key for https://example.com/a, https://EXAMPLE.com:443/b and https://u:[email protected]/c.
  • Probe:
    • --path values health and /health both probe /health, api?x=1 keeps its query, and foo:bar probes /foo:bar as today.
    • --path //other.example.com/x and --path http://other.example.com/x are sent to the target's host. A second host name is the point of these rows.
    • Target https://example.com:8443 probes https://example.com:8443/health, and its OpenAPI base is https://example.com:8443. Target https://example.com probes https://example.com/health. 127.0.0.1:9090 and a sandbox instance's bindings are probed over http, as today.
    • Target [::1]:8080 probes http://[::1]:8080/health. fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112's _parse_target_endpoint rows pass unchanged.
  • IPv4 builds are unchanged. These pass as they are: tests/test_k8s.py:702-885, tests/test_k8s_service.py:185 and :430, and tests/test_telemetry_collector_export.py:61.
  • Proxy behaviour that is pinned today still holds. These keep passing, and the PR explains any expected value it changes: tests/test_k8s_service_proxy.py:64-150 (including the round trip at :147-150), tests/test_k8s_proxy_addressing.py:54, tests/test_qdrant_cluster_addressing.py:36-68 and tests/test_http_connection_pool.py:227-234.
  • No construct left:
  • All tests are offline: no network, DNS or cluster. Together the new tests take well under 1 s, and uv run devops ci passes. The release note goes in a changelog.d fragment.
  • Pending a person: on a dual-stack or IPv6-only cluster, if one is available, devops k8s configure-urls writes bracketed URLs that the dashboard reaches.

Key questions

  • Should dot segments be refused whatever the caller? Proposed: yes, for every path that reaches the proxy or get_json. That covers a ServiceRef built from a configured k8s:// value or from --path, proxy_path overrides, and get_json paths, including the percent-encoded %2e%2e. No caller has a reason to leave the Service's proxy prefix. How the API server treats encoded dot segments was not measured, so the encoded form is refused too. The probe's --path is left alone, because it carries no credential.
  • Why is the dot-segment test httpx2's normalisation and not a segment check? Decided (owner, 2026-10-03): fixes use reputable libraries and tools, never new hand-rolled parsers, prefix tests or regex validators. The escape comes from httpx2's RFC 3986 normalisation, so the test asks that same code whether it would rewrite the path. A split on / compared with . and .. would be a second, hand-written reading of the path. The same rule keeps --address unsplit.
  • Why not the kubernetes client's connect_get_namespaced_service_proxy_with_path? Proposed: do not use it.
    • In kubernetes 36.0.3 it fills {path} with quote(path, safe=configuration.safe_chars_for_path_param), and that setting defaults to '', so every / in the proxied path becomes %2F.
    • Its path2 argument is sent as a query parameter named path, not as a query string.
    • The Qdrant client needs a base URL plus a prefix (service_proxy.py:275-302), which that call cannot provide.
    • httpx2 is already the transport (service_http.py:53-56).
  • Where do the new functions live? Proposed: append_path goes in the URL module fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112 adds for its origin helper (http/urls.py in that item), because k8s/ and sandbox/ both use it. The dot-segment test and the ServiceRef checks stay in k8s/service_proxy.py. This item adds no module.
  • Who reads the probe target's scheme? Proposed: fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112 reads it once, into the httpx2.Origin it returns. This item uses that origin where the probe URLs are built (probe.py:515, :527), because it rewrites those lines. Until this item lands, probes stay on http, as today.
  • May configure-urls change the written form of a URL it rediscovers? Proposed: yes. The project is pre-1.0, with no compatibility guarantee, and the new form names the same URL (RFC 3986 section 6.2.3) and is what httpx2 sends.
    • A port-80 LoadBalancer is now written as http://192.0.2.10 instead of http://192.0.2.10:80. _should_update_url (networking.py:280-296) sees a different string once and rewrites the value.
    • Host case and internationalised forms do not change in practice: Kubernetes API validation accepts an Ingress host, and a LoadBalancer host name, only as a lower-case DNS-1123 name.

Strategic alignment

Activity

  1. added
    type/bug
    scope/k8s
    scope/security
    priority/p2-medium
    on Oct 3, 2026
  2. added this to the v0.2.32 milestone on Oct 8, 2026
  3. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.32 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: URLs and host keys read by the library that dials, ollama hardening, and pull-request test-quality tooling. Position 2 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.

  4. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1509, merged into release/v0.2.32 as dff7004.

    Summary

    Resolves #1111:

    • Service, node, LoadBalancer, and collector URLs are built with httpx2.URL(scheme=..., host=..., port=...), properly bracketing IPv6 hosts (including ::ffff:192.0.2.1 and scoped fe80::1%eth0).
    • _resolve_accessible_url resolves ports via httpx2.URL(url).origin.port (retaining scheme default ports like port 80 for LoadBalancers) and handles unbracketed IPv6 inputs gracefully without raising.
    • ServiceRef validates namespace, service, and port identifiers against Kubernetes RFC 1123 label constraints (validate_k8s_identifier(..., namespace=True)), raising ServiceAddressError.
    • Refuses dot segments (_has_dot_segments) across ServiceRef, proxy_path, and get_json for direct and k8s:// addresses, preventing directory traversal escapes.
    • resolve_proxy_target and resolve_proxy_connection preserve API server path prefixes and raw encodings, cleanly splitting base URL and prefix.
    • Sandbox probe uses httpx2.Origin to probe https:// targets over HTTPS and appends paths via append_path.
    • port_forward formats addresses using httpx2.URL before subprocess.Popen with fallback to {address}:{lport} on InvalidURL, preventing detached orphan processes.

    Closes #1111

    9 file(s) changed.

    How it was verified

    Check runs at db093f1:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (python): pass
    • Analyze (actions): pass
    • Tests & Coverage: pending
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1111-ipv6-service-urls-and-proxy-boundaries.md:

    No Acceptance Criteria section.

  5. added a commit that references this issue on Oct 9, 2026
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

    priority/p2-mediumscope/k8sscope/securitytype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions