Skip to content

fix: move argument validation before sys.argv access in mkconcore.py (fixes #267)#336

Merged
pradeeban merged 2 commits intoControlCore-Project:devfrom
GaneshPatil7517:fix/mkconcore-arg-validation-v2
Feb 18, 2026
Merged

fix: move argument validation before sys.argv access in mkconcore.py (fixes #267)#336
pradeeban merged 2 commits intoControlCore-Project:devfrom
GaneshPatil7517:fix/mkconcore-arg-validation-v2

Conversation

@GaneshPatil7517
Copy link
Copy Markdown
Contributor

@GaneshPatil7517 GaneshPatil7517 commented Feb 15, 2026

Hey pradeeban sir,

Fixes #267.

mkconcore.py crashes with an IndexError when it is run without arguments. This happens because sys.argv[1], sys.argv[2], and sys.argv[3] are accessed before checking how many arguments were provided.

To fix this, the existing len(sys.argv) < 4 validation is moved earlier in the file so it runs before any sys.argv access. This prevents the script from crashing and allows it to show the usage message properly.

The original check was around line ~207. It is now placed earlier (around line ~140). Since the early exit block is moved, the elif at the original location is changed to if.

No new logic was added. The same validation code is simply moved earlier to avoid the crash. There are no style or whitespace changes.

Diff summary:

  • 1 file changed
  • 6 insertions, 5 deletions

Behavior before:
python mkconcore.pyIndexError: list index out of range

Behavior after:
python mkconcore.py → prints usage message and exits cleanly

Copilot AI review requested due to automatic review settings February 15, 2026 05:07
Copy link
Copy Markdown
Contributor

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

Fixes mkconcore.py crashing with IndexError when invoked without enough CLI arguments by moving the len(sys.argv) validation ahead of any sys.argv[...] access.

Changes:

  • Move the existing len(sys.argv) < 4 early-exit usage check to before sys.argv[1], sys.argv[2], and sys.argv[3] are accessed.
  • Adjust the later branching from elif to if since the earlier check now handles the missing-args case.

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

@pradeeban pradeeban merged commit b84ea1f into ControlCore-Project:dev Feb 18, 2026
6 checks passed
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