Fix --reload interpreting 'serve' command as a file argument#2646
Merged
simonw merged 2 commits intosimonw:mainfrom Feb 26, 2026
Merged
Fix --reload interpreting 'serve' command as a file argument#2646simonw merged 2 commits intosimonw:mainfrom
simonw merged 2 commits intosimonw:mainfrom
Conversation
When hupper spawns the worker process, it calls the function specified by worker_path directly. Using "datasette.cli.serve" causes Click to parse sys.argv without going through the CLI group, so the literal word "serve" from the original command gets treated as a positional file argument. Change the worker path to "datasette.cli.cli" so the worker process goes through the Click group dispatcher, which properly recognizes "serve" as a subcommand and strips it from the argument list. Closes simonw#2123 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
|
Thanks for catching this. |
simonw
added a commit
that referenced
this pull request
Feb 26, 2026
Contributor
Author
|
Thank you for the review! Glad it helps. 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2123. When
datasette serve --reload test_dbis run, theserveword is interpreted as a file argument, causingError: Invalid value for '[FILES]...': Path 'serve' does not exist.Root cause
hupper.start_reloader("datasette.cli.serve")tells hupper to call theserveClick command function directly in the worker process. Since this bypasses thecligroup (which usesclick_default_group.DefaultGroup), Click parsessys.argv[1:]without recognizingserveas a subcommand — treating it as a positional file argument instead.Fix
Change the worker path from
"datasette.cli.serve"to"datasette.cli.cli"so the worker process enters through the CLI group, which properly dispatchesserveas a subcommand.This also handles the case where
serveis omitted (datasette --reload test_db), sinceDefaultGroupcorrectly falls back to the defaultservecommand.Test plan
datasette serve --reload test_dbno longer treatsserveas a filedatasette --reload test_db(implicit serve) continues to workThis PR was created with the assistance of Claude Opus 4.6 by Anthropic. Happy to make any adjustments!
📚 Documentation preview 📚: https://datasette--2646.org.readthedocs.build/en/2646/