Skip to content

fix (cmd) : URL Port Corrupts Input in Import-URL Command#465

Open
aniket866 wants to merge 1 commit into
microcks:masterfrom
aniket866:fix/parsing-for-port-url
Open

fix (cmd) : URL Port Corrupts Input in Import-URL Command#465
aniket866 wants to merge 1 commit into
microcks:masterfrom
aniket866:fix/parsing-for-port-url

Conversation

@aniket866

@aniket866 aniket866 commented Jun 18, 2026

Copy link
Copy Markdown

Description

The import-url command parses arguments formatted as url:primary:secret. It uses strings.Split(f, ":") and reconstructs the URL by concatenating the first two elements. If the URL contains a port number (e.g. http://localhost:8585/spec.yaml), the split splits it into ["http", "//localhost", "8585/spec.yaml"]. The code then drops the port and path, changing the URL to http://localhost.

Reason Why It Is Valid

It breaks importing artifacts from local test instances or any custom web server that runs on a non-default port (containing a colon).

Bug Simulation Workflow

graph TD
    A["User runs: microcks import-url http://localhost:8585/api.yaml"] --> B["Split by ':' produces http, //localhost, 8585/api.yaml"]
    B --> C["Reconstruction: urlAndMainAtrifactAndSecretName[0] + ':' + urlAndMainAtrifactAndSecretName[1]"]
    C --> D["Resulting URL is http://localhost"]
    D --> E["API import request sent to http://localhost instead of http://localhost:8585/api.yaml"]
Loading

after fix:

  • importURL.go

Replace the simple : splitting logic with a more robust parser that checks segments from the right end of the string to identify the optional main and secret parameters.

  • [NEW]
    importURL_test.go

Add unit tests to verify the parsing logic for various URL combinations, including:

  • Standard URLs (no port, no suffixes)
  • URLs with ports (no suffixes)
  • URLs with ports and main suffix
  • URLs with ports, main suffix, and secret suffix
  • Standard URLs with main and secret suffixes

Closes #463
@lbroudoux @Harsh4902
do checkout whenever you get time

Signed-off-by: aniket866 <iamaniketkumarmaner@gmail.com>
@aniket866 aniket866 force-pushed the fix/parsing-for-port-url branch from 71d9bc2 to 3fb94dc Compare June 19, 2026 17:53
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.

URL Port Corrupts Input in Import-URL Command

1 participant