Skip to content

Fix CLI exit code for failed commands #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ved1beta
Copy link

@ved1beta ved1beta commented Apr 4, 2025

Fix CLI exit code for failed commands

The CLI was returning exit code 0 (success) even when commands like naptha run failed with errors. This is incorrect behavior, as command failures should return non-zero exit codes to properly signal failure to the calling process.

Changes

  • Added error status checking in the run function for all module types (agent, tool, orchestrator, environment, kb, memory)
  • When a module run completes with error status, it now raises an exception with the error message
  • Improved error message formatting in the CLI to match the expected format
  • Module type validation now properly raises an exception with non-zero exit code

Testing

Verified that:

  • Successful commands continue to return exit code 0
  • Failed commands (like Server 500 errors) now correctly return exit code 1
  • Error messages maintain the format shown in the issue

This fix ensures shell scripts and automation tools can properly detect when Naptha commands fail, allowing for better error handling in CI/CD pipelines and scripts that use the Naptha CLI.

fix #130

@ved1beta ved1beta changed the title Added error status checking in the run Fix CLI exit code for failed commands Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

CLI returns exit code 0 despite naptha run failed
1 participant