{"record":{"id":"9ce7b7c08232a7ec","repo":"521xueweihan/HelloGitHub","slug":"input-error-need-a-param","errorCode":null,"errorMessage":"Input error: Need a param","messagePattern":"Input error: Need a param","errorType":"exception","errorClass":"InputError","httpStatus":null,"severity":"error","filePath":"script/make_content/make_content.py","lineNumber":86,"sourceCode":"    print('Make 《GitHub月刊{num}》 successful！'.format(num=num))\n\n\ndef make_all_content():\n    dir_list = os.listdir(os.path.abspath(os.curdir))\n    for fi_dir in dir_list:\n        # 忽略‘script’的目录\n        if os.path.isdir(fi_dir) and 'script' not in fi_dir:\n            make_content(fi_dir)\n\n\ndef main():\n    \"\"\"\n    入口方法\n    \"\"\"\n    input_list = sys.argv  # 获取输入的参数\n\n    if len(input_list) != 2:\n        raise InputError('Input error: Need a param')\n    else:\n        try:\n            input_arg = input_list[1]\n        except Exception:\n            raise InputError('Input error: Must be number')\n    if len(input_arg) == 1:\n        make_content('0' + input_arg)\n    elif input_arg == 'all':\n        make_all_content()\n    else:\n        make_content(input_arg)\n\nif __name__ == '__main__':\n    main()\n","sourceCodeStart":68,"sourceCodeEnd":101,"githubUrl":"https://github.com/521xueweihan/HelloGitHub/blob/1bbd16c33ee26440f1316ffb0285c603fa541497/script/make_content/make_content.py#L68-L101","documentation":"This is a custom InputError raised by the HelloGitHub monthly-issue generator script (script/make_content/make_content.py:86). It is raised in main() when the script is not invoked with exactly one command-line argument (sys.argv must have length 2: the script name plus one argument). The expected argument is either a period number (e.g. '01' or '1') or the literal string 'all' to regenerate every issue.","triggerScenarios":"Running `python make_content.py` with no arguments, or with more than one argument (e.g. `python make_content.py 01 02`), makes len(sys.argv) != 2 true and raises InputError('Input error: Need a param'). Exactly one argument avoids it.","commonSituations":"Running the script from the wrong directory or via an IDE/PyCharm run configuration that passes no or extra arguments; invoking it through a shell alias or Makefile target that drops the argument; copy-pasting a command with a stray extra flag; scheduled/cron execution where the argument was omitted.","solutions":["Run the script with exactly one argument, e.g. `python script/make_content/make_content.py 05` or `python script/make_content/make_content.py all`.","If you hit this from an IDE run configuration, add the period number (or 'all') to the script parameters field.","If you call this from another script or shell wrapper, verify the argument is actually forwarded (e.g. use `\"$@\"` or pass `\"$1\"` explicitly).","Optionally improve main() to print usage and sys.exit(1) instead of raising, so callers see a friendly message."],"exampleFix":"# before\n$ python script/make_content/make_content.py\nInputError: 'Input error: Need a param'\n\n# after\n$ python script/make_content/make_content.py 05\nMake 《GitHub月刊05》 successful！\n\n# or regenerate every issue\n$ python script/make_content/make_content.py all","handlingStrategy":"validation","validationCode":"import sys\n\nargs = sys.argv[1:]\nif len(args) != 1:\n    sys.stderr.write('usage: make_content.py <period-number|all>\\n')\n    sys.exit(1)\n# safe to proceed: exactly one argument was supplied","typeGuard":null,"tryCatchPattern":"from make_content import InputError, main\n\ntry:\n    main()\nexcept InputError as e:\n    sys.stderr.write(str(e.message) + '\\n')\n    sys.exit(2)","preventionTips":["Always invoke the script with exactly one argument: a period number like '05' or the keyword 'all'.","In IDE run configurations, set the script parameter explicitly before running.","When wrapping the script in shell/Makefile, forward the argument with \"$1\" or \"$@\" and quote it."],"tags":["cli","argument-validation","usage-error","python"],"backgroundTag":null,"analyzedSha":"1bbd16c33ee26440f1316ffb0285c603fa541497","analyzedAt":"2026-08-14T15:59:01.911Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}