microcks / microcks/microcks-cli

bug: `import-url` doesn't validate URL scheme, fails with misleading error instead

Open Beginner friendly
#534 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
52
Forks
68
Avg merge
6h 54m
Merged PRs (30d)
10

Description

### Describe the bug

`parseImportURLArg` in `cmd/import_url.go` only parses the `:mainArtifact:secret` suffix when the input starts with `http://` or `https://`. If it doesn't, there's no else, the string just passes through unchanged and gets sent straight to `mc.DownloadArtifact(...)`, which then fails with an unrelated, confusing error.

### How to Reproduce?

```
./microcks import-url "spec.yaml:true:mysecret"
```

### Actual behavior

Image

### Expected behavior

Something like:
```
Error: invalid artifact URL 'spec.yaml:true:mysecret': must start with http:// or https://
```

### Microcks version or git rev

1.0.3

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

_No response_

### Additional information

Fix for this would be to validate the scheme at the top of `parseImportURLArg `and return an error instead of silently falling through, then propagate it in RunE.

Contributor guide

Open the contributing guide

Research direction

Start in cmd/import_url.go at parseImportURLArg and the command's RunE handler. Reproduce the import-url command with a non-HTTP(S) value, then validate the URL scheme and propagate the returned error so the command reports that the artifact URL must start with http:// or https://.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
86/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.