Skip to content

fix(cli): exit non-zero when the crawl profile does not exist - #2568

Open
SoulmatelynchVFX wants to merge 1 commit into
unclecode:developfrom
SoulmatelynchVFX:fix/cli-exit-missing-profile
Open

SoulmatelynchVFX wants to merge 1 commit into
unclecode:developfrom
SoulmatelynchVFX:fix/cli-exit-missing-profile

Conversation

@SoulmatelynchVFX

Copy link
Copy Markdown

crwl crawl on a profile that does not exist prints the error and then returns normally, so the process exits 0:

$ crwl crawl https://example.com --profile nope -O out.md
Profile 'nope' not found. Available profiles: ...
$ echo $?
0

out.md is never written and nothing was crawled, but the exit status says success, so a script that checks $? cannot tell this apart from a completed crawl.

The same file already exits 1 for the equivalent case in crwl profiles delete (Profile not found: → sys.exit(1)), so this looks like an oversight rather than an intended contract.

Change: the early return in the profile lookup becomes sys.exit(1), covering both branches (profile missing / no profiles at all). Both entry points route through crawl_cmd (crwl crawl and crwl <url> -p <name>).

Test: tests/cli/test_cli.py::TestCLIBasics::test_missing_profile_exits_non_zero stubs BrowserProfiler and asserts the runner sees exit code 1.

crwl crawl with an unknown --profile printed the error and returned from
the callback, so the process exited 0 with no output written. Scripts
checking the exit status treated that as a successful crawl. The sibling
profile commands already exit 1 for the same condition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant