Skip to content

fix(cli): raise non-zero exit on import errors#378

Open
SaitejaKommi wants to merge 1 commit intoopenfoodfacts:mainfrom
SaitejaKommi:fix/cli-import-exit-code
Open

fix(cli): raise non-zero exit on import errors#378
SaitejaKommi wants to merge 1 commit intoopenfoodfacts:mainfrom
SaitejaKommi:fix/cli-import-exit-code

Conversation

@SaitejaKommi
Copy link
Copy Markdown

Summary

This PR ensures the import CLI command fails with a non-zero exit status when import errors occur. The command now raises an explicit Typer exit in the error path, making failure detection reliable for CI and scripts.


Related issue


Scope

  • main.py

What changed

  • In the import command flow:
    • When num_errors > 0:
      • Log the error count
      • Raise explicit exit:
        raise typer.Exit(code=1)

Why this is correct

  • Typer requires raising Exit to terminate with a specific status code
  • Ensures CLI behavior aligns with standard Unix conventions
  • Enables reliable failure detection in CI and automation workflows

Testing Done

  • Backend unit tests: passed
  • Backend integration tests: passed (with expected xfailed cases)
  • Frontend test suite: passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Backlog (ready for dev)

Development

Successfully merging this pull request may close these issues.

CLI Import command should exit non-zero when data import reports errors

2 participants