Describe the bug
microcks import-dir can report failed artifact imports but still complete with exit code 0.
The command already tracks failed imports through ImportResult.FailedCount, but after printing the final import summary it does not return a non-zero exit code when FailedCount > 0.
This is problematic for scripts and CI pipelines because a partial import failure is treated as a successful command execution.
Expected behavior
When one or more files fail to import, microcks import-dir should:
- continue processing the remaining files
- print the import summary
- exit with a non-zero status code, for example
1
If all files are imported successfully, it should continue exiting with status code 0.
Actual behavior
When ImportDirectory completes with partial failures, the command prints the failed files and final summary, but then returns normally.
Because the Cobra command returns without calling os.Exit(1) or returning an error, the process exits with status code 0.
How to Reproduce?
This can be observed from the current command flow in cmd/importDir.go.
Reproducer:
- Make
ImportDirectory process multiple specification files.
- Have one
UploadArtifact call fail while another succeeds.
ImportDirectory returns a result with FailedCount > 0 and err == nil.
NewImportDirCommand prints the summary but does not check result.FailedCount.
- The command returns normally, so the process exits with status code
0.
The existing unit test TestImportDirectory/partial_failure already demonstrates the partial-failure case at the business-logic level: one file succeeds, one file fails, and FailedCount is set to 1.
Resources to reproduce the behaviour:
cmd/importDir.go
cmd/importDir_test.go
- Existing test case:
TestImportDirectory/partial_failure
Microcks version or git rev
Microcks-CLI 1.0.2
Install method (docker-compose, helm chart, operator, docker-desktop extension,...)
No response
Additional information
A possible fix is to check result.FailedCount after printing the summary:
if result.FailedCount > 0 {
os.Exit(1)
}
Describe the bug
microcks import-dircan report failed artifact imports but still complete with exit code0.The command already tracks failed imports through
ImportResult.FailedCount, but after printing the final import summary it does not return a non-zero exit code whenFailedCount > 0.This is problematic for scripts and CI pipelines because a partial import failure is treated as a successful command execution.
Expected behavior
When one or more files fail to import,
microcks import-dirshould:1If all files are imported successfully, it should continue exiting with status code
0.Actual behavior
When
ImportDirectorycompletes with partial failures, the command prints the failed files and final summary, but then returns normally.Because the Cobra command returns without calling
os.Exit(1)or returning an error, the process exits with status code0.How to Reproduce?
This can be observed from the current command flow in
cmd/importDir.go.Reproducer:
ImportDirectoryprocess multiple specification files.UploadArtifactcall fail while another succeeds.ImportDirectoryreturns a result withFailedCount > 0anderr == nil.NewImportDirCommandprints the summary but does not checkresult.FailedCount.0.The existing unit test
TestImportDirectory/partial_failurealready demonstrates the partial-failure case at the business-logic level: one file succeeds, one file fails, andFailedCountis set to1.Resources to reproduce the behaviour:
cmd/importDir.gocmd/importDir_test.goTestImportDirectory/partial_failureMicrocks version or git rev
Microcks-CLI 1.0.2
Install method (
docker-compose,helm chart,operator,docker-desktop extension,...)No response
Additional information
A possible fix is to check
result.FailedCountafter printing the summary: