Skip to content

CI/CD Pipeline False Positives: import-dir Exits with Code 0 on Failures #473

Description

@aniket866

Describe the bug

Description

The import-dir command scans a directory and attempts to import all matching files. If one or more files fail to import, it records the failure in ImportResult.FailedCount and prints an error message. However, the command runner does not check the failed count to return a non-zero exit code.

Impact

In CI/CD environments (GitHub Actions, Tekton, GitLab CI), the CLI exits with status 0, indicating success even if all API specifications failed to import. This hides deployment failures.

Code Reference

  • cmd/importDir.go

Diagram

graph TD
    A[Start import-dir] --> B[Scan Directory]
    B --> C[Import File 1: Success]
    B --> D[Import File 2: FAILED]
    C & D --> E[Display Results Summary]
    E --> F["Exit Status Code 0 (Success)"]
    F --> G["CI/CD pipeline reports green/success despite failures"]
Loading

Steps to Reproduce

  1. Run microcks import-dir ./specs where at least one spec has invalid content.
  2. The console displays ✗ Failed: ....
  3. Check the exit code of the process (echo $? or $LASTEXITCODE in PowerShell). It returns 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions