521xueweihan/HelloGitHub · error · InputError
Input error: Need a param
Error message
Input error: Need a param
What it means
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.
Source
Thrown at script/make_content/make_content.py:86
print('Make 《GitHub月刊{num}》 successful!'.format(num=num))
def make_all_content():
dir_list = os.listdir(os.path.abspath(os.curdir))
for fi_dir in dir_list:
# 忽略‘script’的目录
if os.path.isdir(fi_dir) and 'script' not in fi_dir:
make_content(fi_dir)
def main():
"""
入口方法
"""
input_list = sys.argv # 获取输入的参数
if len(input_list) != 2:
raise InputError('Input error: Need a param')
else:
try:
input_arg = input_list[1]
except Exception:
raise InputError('Input error: Must be number')
if len(input_arg) == 1:
make_content('0' + input_arg)
elif input_arg == 'all':
make_all_content()
else:
make_content(input_arg)
if __name__ == '__main__':
main()
View on GitHub (pinned to 1bbd16c33e)
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.
Example fix
# before $ python script/make_content/make_content.py InputError: 'Input error: Need a param' # after $ python script/make_content/make_content.py 05 Make 《GitHub月刊05》 successful! # or regenerate every issue $ python script/make_content/make_content.py all
Defensive patterns
Strategy: validation
Validate before calling
import sys
args = sys.argv[1:]
if len(args) != 1:
sys.stderr.write('usage: make_content.py <period-number|all>\n')
sys.exit(1)
# safe to proceed: exactly one argument was supplied Try / catch
from make_content import InputError, main
try:
main()
except InputError as e:
sys.stderr.write(str(e.message) + '\n')
sys.exit(2) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of 521xueweihan/HelloGitHub@1bbd16c33e (2026-08-14).
Data as JSON: /api/errors/9ce7b7c08232a7ec.
Report an issue: GitHub.