microcks-cli icon indicating copy to clipboard operation
microcks-cli copied to clipboard

Bug: import-url loses URL path/port when parsing :primary and secret suffixes

Open cotishq opened this issue 7 months ago β€’ 9 comments

Describe the bug

The import-url command parses artifact URLs with strings.Split(f, ":").

This breaks normal URLs that contain additional colons, for example URLs with ports:

http://localhost:8080/spec.yaml:true

The current parsing logic reconstructs the URL from only the first two split parts:

f = urlAndMainAtrifactAndSecretName[0] + ":" + urlAndMainAtrifactAndSecretName[1]

So http://localhost:8080/spec.yaml:true becomes http://localhost, losing the port, path, and filename.

This affects import-url when using the optional :primary and secret suffixes.

Expected behavior

import-url should preserve the full URL, including scheme, host, port, path, query string, and fragment.

For example:

microcks import-url http://localhost:8080/spec.yaml:true

should send this URL to microcks:

http://localhost:8080/spec.yaml

with mainArtifact=true.

URLs without suffixes should also continue to work unchanged.

Actual behavior

The URL is split on every colon. For a URL like:

http://localhost:8080/spec.yaml:true

the parser splits it into parts like:

["http", "//localhost", "8080/spec.yaml", "true"]

Then it reconstructs only:

http://localhost

As a result, Microcks receives an incorrect artifact URL.

How to Reproduce?

Reproducer:

  1. Run import-url with a URL that contains a port and the :primary suffix:
microcks import-url http://localhost:8080/spec.yaml:true \
  --microcksURL=http://localhost:8080/api \
  --keycloakClientId=<client-id> \
  --keycloakClientSecret=<client-secret>
  1. Observe that the CLI parses the artifact URL incorrectly before calling DownloadArtifact.
Image

Microcks version or git rev

Microcks CLI 1.0.2

Install method (docker-compose, helm chart, operator, docker-desktop extension,...)

built from source

Additional information

A possible fix is to avoid splitting the whole URL on every colon.

Options:

  • parse suffixes from the right side only, for example with strings.LastIndex;
  • use URL-aware parsing and only treat trailing :true, :false, and optional secret values as CLI metadata;
  • add focused unit tests for URLs with ports, paths, query strings, and suffixes.

Related code:

urlAndMainAtrifactAndSecretName := strings.Split(f, ":")
n := len(urlAndMainAtrifactAndSecretName)
f = urlAndMainAtrifactAndSecretName[0] + ":" + urlAndMainAtrifactAndSecretName[1]

cotishq avatar May 02 '26 06:05 cotishq

πŸ‘‹ @cotishq

Welcome to the Microcks community! πŸ’–

Thanks and congrats πŸŽ‰ for opening your first issue here! Be sure to follow the issue template or please update it accordingly.

πŸ“’ If you're using Microcks in your organization, please add your company name to this list. πŸ™ It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community πŸ™Œ"

Hope you have a great time there!

github-actions[bot] avatar May 02 '26 06:05 github-actions[bot]

@Harsh4902 would love to hear your opinion, and if this looks good i can raise a pr for it

cotishq avatar May 02 '26 06:05 cotishq

hey, i can take this.. already have a fix using strings.LastIndex to grab the suffix from the right instead of splitting on every : will open a PR once that’s confirmed πŸ‘

rubrx avatar May 02 '26 20:05 rubrx

hey, i can take this.. already have a fix using strings.LastIndex to grab the suffix from the right instead of splitting on every : will open a PR once that’s confirmed πŸ‘

Hey, i am working on it, once maintainer approves it, I'll raise the pr too

cotishq avatar May 02 '26 21:05 cotishq

Okay...Got it, thanks! I’ll hold off πŸ‘

rubrx avatar May 02 '26 21:05 rubrx

@lbroudoux hey, whats your opinion on this, can i work on this

cotishq avatar May 04 '26 12:05 cotishq

Yes, for sure. We don't assign issues to non-codeowners of the repo. So anytime you want to contribute, please signal your interest in joining an issue discussion to advertise that you're ready to tackle this topic. This will let the others know what you're working on.

lbroudoux avatar May 04 '26 12:05 lbroudoux

ya i will keep this in consideration next time

cotishq avatar May 04 '26 12:05 cotishq

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 30 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. Microcks is a Cloud Native Computing Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Jun 05 '26 01:06 github-actions[bot]

It should be /keep-open

Vaishnav88sk avatar Aug 15 '26 12:08 Vaishnav88sk