Repository navigation
Reject a -sites list with no site keys instead of panicking - #23
Conversation
`crawl -sites ","` resolved to an empty key list but was accepted, so the single-site path indexed siteKeys[0] and panicked. `watch -sites ","` started and idled forever watching zero sites. Treat a -sites value with no keys as if it was not given. Both commands now print "one of -site, -sites, or --all-sites is required" and exit 1, and an empty -sites next to a -site no longer discards that -site. Fixes Sriram-PR#13
|
Thanks for the fix, and for flagging the Let's keep that combination working but make it visible: when Please update the |
|
Added the warning you asked for: |
|
Thanks, this looks great. I checked the new warning with both crawl and watch, confirmed that -sites "," on its own now exits 1 with the usual selector error, and reran the other combinations. All behave as expected. Merging now. Thanks for the clear write-up and the AI disclosure! |
Fixes #13.
resolveSiteKeysaccepted any non-empty-sitesstring, even one with no keys in it. Forcrawl -sites ","that meant an empty list on the single-site path, sositeKeys[0]panicked with exit 2. Forwatch -sites ","the scheduler started with zero sites and idled forever.Now
-sitesonly counts as a selector when it yields at least one key. Otherwise it's treated as not given, so both commands printError: one of -site, -sites, or --all-sites is requiredwith exit 1, the same as passing no selector. One side effect worth calling out:-site a -sites ","now crawlsawith no warning, where before it warned and then dropped-site. If you'd rather that combination be an error, I can change it.The
runtask-spec path already rejects blanksitesentries inTaskSpec.Validate, so it isn't affected.Testing:
TestResolveSiteKeyswith","," , ,"," "and-site a -sites ",". These failed before the change.crawl -sites ","andwatch -sites " , ". Both now exit 1 with the error above.go test -race ./cmd/...,go test ./...,go vet ./...,golangci-lint run ./...andgolangci-lint fmt --diff ./...are all clean.AI disclosure: I used an AI coding assistant to help write this change and the test. I reviewed the diff and ran the checks above locally.