fix: prevent IndexError in mkconcore.py when arguments are missing (fixes #267)#308
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes Issue #267 where mkconcore.py crashes with an IndexError when run without required command-line arguments. The script was accessing sys.argv[1], sys.argv[2], and sys.argv[3] before validating the argument count, causing crashes instead of displaying helpful usage information.
Changes:
- Moved argument validation check (
len(sys.argv) < 4) from line 157 to line 109, before anysys.argvaccess - Added usage message that displays when arguments are missing
- Removed redundant late validation block that was unreachable
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Looks like many lines are changed without reason in addition to the actual change. Can you pls recreate the PR with the least number of lines changed? Probably this is a lone break change in many lines? The minimal line changes will help avoid merge conflicts and maintain the actual author when a line was not really changed (helps with "git blame") |
@pradeeban
Summary
This PR resolves Issue #267 where
mkconcore.pycrashes with anIndexErrorwhen executed without required arguments.The script accessed
sys.argv[1],sys.argv[2], andsys.argv[3]before validating the number of arguments. As a result, running:produced:
instead of a helpful usage message.
Changes Made
len(sys.argv) < 4) before any access tosys.argvelementsprint()sys.exit(1))Behavior After Fix
Scope
mkconcore.py