fix(config): Strip urls only if fully qualified - #433
Open
craciunoiuc wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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/v1registers the client as127, andhttp://proxy.example.test/v1asproxy, while resource selection uses the endpoint authority (the same mismatch described in the PR forlocalhost: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.
Signed-off-by: Cezar Craciunoiu <cezar@unikraft.io>
craciunoiuc
force-pushed
the
craciunoiuc/allow-localhost-metro
branch
from
July 28, 2026 14:39
564c70c to
765ae6e
Compare
jedevc
reviewed
Jul 28, 2026
| 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") |
Member
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So if you look at the parse it used string parsing. This means that the
/v1suffix stayed in the host variable aka the name of the node.Or maybe you like the AI explanation better:
Closes: TOOL-1140