Skip to content

Fix mrindex --start-uuid flag not being recognized#1045

Open
ericnewcomer wants to merge 1 commit intomainfrom
ericnewcomer/fix-mrindex-start-uuid
Open

Fix mrindex --start-uuid flag not being recognized#1045
ericnewcomer wants to merge 1 commit intomainfrom
ericnewcomer/fix-mrindex-start-uuid

Conversation

@ericnewcomer
Copy link
Copy Markdown
Member

Summary

  • mrindex --start-uuid was broken because LoadConfig (via ezconf) parses os.Args first and rejects unknown flags before mrindex's own flag parser runs
  • Fix moves mrindex's flag parsing before LoadConfig and strips custom flags from os.Args so ezconf only sees args it understands

Test plan

  • Run mrindex --start-uuid=<uuid> contacts and verify it no longer errors with "flag provided but not defined"
  • Run mrindex contacts and mrindex messages without --start-uuid to verify they still work

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 13, 2026 18:28
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.
@ericnewcomer ericnewcomer force-pushed the ericnewcomer/fix-mrindex-start-uuid branch from db2a61b to 0478c9a Compare April 13, 2026 18:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 calling runtime.LoadConfig.
  • Strips mrindex-specific flags from os.Args so ezconf only sees arguments it understands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/index.go
Comment on lines +24 to +27
// 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:])
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.43%. Comparing base (485e448) to head (0478c9a).

Files with missing lines Patch % Lines
cmd/index.go 0.00% 7 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants