Skip to content

fix: import-url command exits early on first failure when importing multiple URLs #399

Description

@A-d-i-t-y

Why we need this:
When importing multiple comma-separated URLs, if one URL fails,
the command immediately exits and remaining URLs are never imported.
This is the same issue that was fixed in the import command in PR #394.

How this will help:
All URLs should be attempted regardless of individual failures,
giving users complete feedback in one run.

Motivation:
Consistent behavior across all import commands (import, import-url).

Problem

When running:
microcks import-url "https://url1.yaml,https://url2.yaml,https://url3.yaml"

If url1 fails, os.Exit(1) is called immediately inside the loop
and url2, url3 are never imported.

Looking at cmd/importURL.go:
for _, f := range sepSpecificationFiles {
msg, err := mc.DownloadArtifact(f, mainArtifact, secret)
if err != nil {
os.Exit(1) // exits immediately, remaining URLs skipped
}
}

Same bug as #393, fixed in import command via PR #394.

Fix

  • Collect errors instead of exiting immediately
  • Attempt all URLs regardless of individual failures
  • Exit with code 1 only if any URL failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions