fix (cmd) : URL Port Corrupts Input in Import-URL Command - #465
Conversation
71d9bc2 to
3fb94dc
Compare
|
hi @Harsh4902 do checkout this one , whenever you get time |
|
Since #460 also touches Otherwise, LGTM. |
3fb94dc to
a985662
Compare
@Vaishnav88sk |
|
The original However, this PR is no longer scoped to that fix only. It now includes several unrelated changes as well, including:
Please keep this PR focused on the |
0788d95 to
c0df99e
Compare
|
Please pass the DCO. |
…e failure in import-url Signed-off-by: aniket866 <iamaniketkumarmaner@gmail.com>
c0df99e to
a4b8f37
Compare
done |
|
LGTM |
Description
The
import-urlcommand parses arguments formatted asurl:primary:secret. It usesstrings.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 tohttp://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"]after fix:
importURL.goReplace 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.
importURL_test.goAdd unit tests to verify the parsing logic for various URL combinations, including:
Closes #463
@lbroudoux @Harsh4902
do checkout whenever you get time