← Back to issue list

Unhelpful error message when creating help if an argument doesn't have a help text

View original Github issue

Metadata

Project
craft-cli
Number
#242
Type
issue
State
open
Author
lengau
Labels
—
Created
Updated
Closed
—

Current evaluation

Help output for a command whose argument lacks help text renders badly (originally IndexError) instead of a clear error. Maintainer directed resolution to PR #481 (fail early on missing help), which is still open.

Suggested action: keep open

Reason: Maintainer lengau filed this and cmatsuoka replied 33 days ago: "#481 makes applications fail early in case of missing help messages. The alternative would be to fail more gracefully in case when using the help command, but requiring help messages to exist feels like better UX in general." That establishes the intended fix and an implementing PR, which is still open per its record, so the issue is triaged and should stay open. Note that the original IndexError no longer reproduces at HEAD: helptexts.py:72 now guards with `if wrapped_lines:` (added in commit 6dab8d6, "fix: hide positional arguments with no help"), so the concrete symptom in the traceback is mitigated and the remaining ask is the clearer error from #481.

Evaluated by: mr-cal-bot

Impact: 32 Quick Win: 17 Complexity: 35 Confidence: 76 Actionability: 82

Issue body

### Bug Description If a command adds an argument without `help` text, the error raised isn't very useful. It should give a better error. ### To Reproduce ``` import sys import craft_cli class ExampleCommand(craft_cli.BaseCommand): name = "example" help_msg = overview = "unimportant" def fill_parser(self, parser): parser.add_argument("--do-something") craft_cli.emit.init(craft_cli.EmitterMode.BRIEF, "example-app", "example app") dispatcher = craft_cli.Dispatcher( "example-app", [craft_cli.CommandGroup("Example", [ExampleCommand])], summary="summary" ) dispatcher.pre_parse_args(sys.argv[1:]) dispatcher.load_command(None) dispatcher.run() ``` `python ./example.py help example` ### part yaml ```shell n/a ``` ### Relevant log output ```shell Traceback (most recent call last): File "/home/lengau/Work/Code/charmcraft-2/charmcraft/application/commands/example.py", line 22, in <module> dispatcher.pre_parse_args(sys.argv[1:]) File "/home/lengau/Work/Code/charmcraft-2/.venv/lib/python3.11/site-packages/craft_cli/dispatcher.py", line 469, in pre_parse_args help_text = self._get_requested_help(cmd_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/lengau/Work/Code/charmcraft-2/.venv/lib/python3.11/site-packages/craft_cli/dispatcher.py", line 355, in _get_requested_help return self._help_builder.get_command_help(command, command_options, output_format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/lengau/Work/Code/charmcraft-2/.venv/lib/python3.11/site-packages/craft_cli/helptexts.py", line 425, in get_command_help textblocks = builder(usage, command.overview, options, other_command_names) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/lengau/Work/Code/charmcraft-2/.venv/lib/python3.11/site-packages/craft_cli/helptexts.py", line 312, in _build_plain_command_help option_lines.extend(_build_item_plain(title, text, max_title_len)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/lengau/Work/Code/charmcraft-2/.venv/lib/python3.11/site-packages/craft_cli/helptexts.py", line 71, in _build_item_plain first = f" {title:>{title_space}s}: {wrapped_lines[0]}" ~~~~~~~~~~~~~^^^ IndexError: list index out of range ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 32
Quick Win: 17
Complexity: 35
Confidence: 76
Actionability: 82
keep open Help output for a command whose argument lacks help text renders badly (originally IndexError) instead of a clear error. Maintainer directed resolution to PR #481 (fail early on missing help), which is still open.
qwen/qwen3.6-35b-a3b
Impact: 30
Quick Win: 19
Complexity: 20
Confidence: 80
Actionability: 80
keep open IndexError crash when running help on a command with an argument missing help text. PR #481 addresses this but is still open.
qwen/qwen3.8-27b
Impact: 45
Quick Win: 27
Staleness: 10
Complexity: 40
Confidence: 80
Support Request: 10
keep open craft-cli raised an unhelpful IndexError when a command argument lacked help text; the crash is now guarded in helptexts.py, and maintainer cmatsuoka is addressing the root cause via open PR #481 (fail early on missing help).
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 20
Confidence: 85
Support Request: 0
close stale Unhelpful IndexError when creating help for an argument without help text. Issue is 880 days old, inactive, and lacks maintainer engagement.
qwen3.6-35b-a3b-mtp-q6
Staleness: 95
Complexity: 20
Confidence: 80
Support Request: 0
close stale Unhelpful IndexError when generating help for arguments missing help text. Issue remains unlabelled and inactive for over two years with no maintainer engagement.

Update history

Date Change
updated

Related work

  • Likely Fixed By: canonical/craft-cli#481 (confidence 80%)

    PR 'feat: error early when help message is missing' implements the approach the maintainer endorsed in the comment; still open, so not yet merged.

Related issues

Issue Project State Summary Similarity
#481 feat: error early when help message is missing craft-cli open Raises a CommandError during help generation when an argument lacks help text, fixing the IndexError from #242. Small 2-file diff (+52/-50), all CI checks green; awaiting maintainer review with 1 unresolved comment, inactive 32 days.
74%