Skip to content

Handle a blank endpoint or parameter description without crashing - #121

Open
arpitjain099 wants to merge 1 commit into
fermitools:masterfrom
arpitjain099:fix/blank-description-indexerror
Open

arpitjain099 wants to merge 1 commit into
fermitools:masterfrom
arpitjain099:fix/blank-description-indexerror

Conversation

@arpitjain099

Copy link
Copy Markdown

FerryParser.parse_description wraps the description and then takes description_lines[0] unconditionally. textwrap.wrap returns an empty list for an empty or whitespace-only string, so a blank description raises IndexError instead of producing a help line.

It is reachable from normal startup. generate_endpoints passes data[method]["description"] straight into create_subparser, and set_arguments passes each param["description"] in too, so a single endpoint or parameter with an empty description aborts endpoint generation for the whole CLI.

I drove generate_endpoints against small local swagger files. A well-formed one builds its endpoint; an endpoint with "description": "" and a parameter with "description": " " both raised IndexError: list index out of range before this change and build fine after. The new tests fail on master and pass with the fix, and the rest of the suite is unchanged (the 4 test_api.py errors are a missing local htgettoken, either way).

FerryCLI.parse_description has the same unguarded indexing but no callers, so I left it out rather than widen this PR. Happy to include it if you would rather they matched.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
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.

1 participant