Fix mrindex --start-uuid flag not being recognized#1045
Fix mrindex --start-uuid flag not being recognized#1045ericnewcomer wants to merge 1 commit intomainfrom
Conversation
LoadConfig uses ezconf which parses os.Args and rejects unknown flags, so --start-uuid was rejected before mrindex's own flag parser could run. Move flag parsing before LoadConfig and strip custom flags from os.Args.
db2a61b to
0478c9a
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes mrindex --start-uuid being rejected during startup because runtime.LoadConfig (via ezconf) parses os.Args and errors on unknown flags before mrindex’s own flag parsing runs.
Changes:
- Parses mrindex-specific flags (
--start-uuid) before callingruntime.LoadConfig. - Strips mrindex-specific flags from
os.Argsso ezconf only sees arguments it understands.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // parse mrindex-specific flags before LoadConfig which also parses os.Args | ||
| flags := flag.NewFlagSet("mrindex", flag.ExitOnError) | ||
| startUUID := flags.String("start-uuid", "", "UUID to start from (messages mode only, works backwards from here)") | ||
| flags.Parse(os.Args[1:]) |
There was a problem hiding this comment.
Parsing os.Args[1:] with a FlagSet that only defines --start-uuid will exit on any of the runtime/ezconf config flags (e.g. --db, --log-level, --help), which are documented as supported command-line parameters and are exercised in runtime.LoadConfig tests. This change fixes --start-uuid but introduces a regression where mrindex can no longer accept config flags. Prefer extracting/removing just the --start-uuid option from the args (e.g. via a small pre-scan that handles both --start-uuid=... and --start-uuid ...) while leaving all other args intact for LoadConfig, or call runtime.LoadConfig(filteredArgs...) without invoking flag.Parse on the full argument list upfront.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1045 +/- ##
==========================================
- Coverage 52.44% 52.43% -0.01%
==========================================
Files 275 275
Lines 12684 12685 +1
==========================================
Hits 6652 6652
- Misses 5189 5190 +1
Partials 843 843 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
mrindex --start-uuidwas broken becauseLoadConfig(via ezconf) parsesos.Argsfirst and rejects unknown flags before mrindex's own flag parser runsLoadConfigand strips custom flags fromos.Argsso ezconf only sees args it understandsTest plan
mrindex --start-uuid=<uuid> contactsand verify it no longer errors with "flag provided but not defined"mrindex contactsandmrindex messageswithout--start-uuidto verify they still work🤖 Generated with Claude Code