Skip to content

fix(config): Strip urls only if fully qualified - #433

Open
craciunoiuc wants to merge 1 commit into
prod-stagingfrom
craciunoiuc/allow-localhost-metro
Open

fix(config): Strip urls only if fully qualified#433
craciunoiuc wants to merge 1 commit into
prod-stagingfrom
craciunoiuc/allow-localhost-metro

Conversation

@craciunoiuc

@craciunoiuc craciunoiuc commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

So if you look at the parse it used string parsing. This means that the /v1 suffix stayed in the host variable aka the name of the node.

Or maybe you like the AI explanation better:

URL parser derived name before removing /v1 → client registered as localhost:8080/v1; resource requests select localhost:8080 → missing client.

Closes: TOOL-1140

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates environment-based metro parsing to correctly handle local proxy URLs.

Changes:

  • Derives metro names using net/url.
  • Adds coverage for localhost:8080/v1.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/config/profile.go Parses metro URL hosts before deriving names.
internal/config/config_test.go Tests local proxy URL parsing.
Comments suppressed due to low confidence (1)

internal/config/profile.go:124

  • The new local-proxy handling still truncates dotted proxy hosts: http://127.0.0.1:8080/v1 registers the client as 127, and http://proxy.example.test/v1 as proxy, while resource selection uses the endpoint authority (the same mismatch described in the PR for localhost:8080). Preserve the full authority for non-Unikraft proxy hosts and only derive the first label for known cloud API hostnames.
		host := strings.TrimPrefix(u.Host, "api.")
		name, _, _ = strings.Cut(host, ".")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/config/profile.go Outdated
Signed-off-by: Cezar Craciunoiu <cezar@unikraft.io>
@craciunoiuc
craciunoiuc force-pushed the craciunoiuc/allow-localhost-metro branch from 564c70c to 765ae6e Compare July 28, 2026 14:39
if u, err := url.Parse(endpoint); err == nil && u.IsAbs() && u.Host != "" {
host := strings.TrimPrefix(u.Host, "api.")
name, _, _ = strings.Cut(host, ".")
endpoint = strings.TrimSuffix(strings.TrimSuffix(endpoint, "/"), "/v1")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of doing this then, can't we just reformat the URL?

Or alternatively, just share the /v1 stripping between name + endpoint.

I like the idea of moving away from just string - based parsing, but we should then do it for the endpoint as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants