prepare-upload does not provide usage help when a subcommand is not specified

Bug #1947138 reported by Christian Ehrhardt 
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
git-ubuntu
Triaged
Medium
Unassigned

Bug Description

Don't know yet what it is, but I found repro:

$ git ubuntu clone open-vm-tools
$ cd open-vm-tools/
$ git checkout -b test
$ dch -i "test"
$ git commit -s -m "changelog: test" debian/changelog
$ git ubuntu prepare-upload
Traceback (most recent call last):
  File "/snap/git-ubuntu/661/usr/bin/git-ubuntu", line 11, in <module>
    load_entry_point('gitubuntu==1.0', 'console_scripts', 'git-ubuntu')()
  File "/snap/git-ubuntu/661/usr/lib/python3/dist-packages/gitubuntu/__main__.py", line 191, in main
    args = parser.parse_args()
  File "/snap/git-ubuntu/661/usr/lib/python3.8/argparse.py", line 1780, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/snap/git-ubuntu/661/usr/lib/python3.8/argparse.py", line 1812, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/snap/git-ubuntu/661/usr/lib/python3.8/argparse.py", line 2021, in _parse_known_args
    stop_index = consume_positionals(start_index)
  File "/snap/git-ubuntu/661/usr/lib/python3.8/argparse.py", line 1977, in consume_positionals
    take_action(action, args)
  File "/snap/git-ubuntu/661/usr/lib/python3.8/argparse.py", line 1886, in take_action
    action(self, namespace, argument_values, option_string)
  File "/snap/git-ubuntu/661/usr/lib/python3.8/argparse.py", line 1171, in __call__
    subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
  File "/snap/git-ubuntu/661/usr/lib/python3.8/argparse.py", line 1812, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/snap/git-ubuntu/661/usr/lib/python3.8/argparse.py", line 2047, in _parse_known_args
    ', '.join(required_actions))
TypeError: sequence item 0: expected str instance, NoneType found

Revision history for this message
Robie Basak (racb) wrote :

Yes this is what I meant by error handling not being good in the beta.

"git ubuntu prepare-upload" requires a further subcommand - "args" or "mangle". You probably want "args"?

The problem here is that argparse crashes instead of providing useful usage text.

Changed in usd-importer:
status: New → Triaged
importance: Undecided → Medium
summary: - prepare-upload - TypeError: sequence item 0: expected str instance,
- NoneType found
+ prepare-upload does not provide usage help when a subcommand is not
+ specified
tags: added: prepare-upload
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

As I said on MM, I didn't realize you meant literal "args" as argument.
Let us keep the bug open to give it a better more helpful error message in the case it is invoked without args|mangle.

Revision history for this message
Robie Basak (racb) wrote :

This looks like https://bugs.python.org/issue29298 - fixed in the Python in Jammy but present in the Python in Focal. And the git-ubuntu snap currently builds from Focal, so uses Focal's Python.

Revision history for this message
Robie Basak (racb) wrote :

I think cherry-picking https://github.com/python/cpython/commit/097801844c99ea3916bebe1cc761257ea7083d34 would probably fix this, which we could do in an SRU to Focal. There might be an easier workaround I can manage in the code. Or I could try to switch the git-ubuntu snap to core22, but that'd be quite a bit of work.

Revision history for this message
Robie Basak (racb) wrote :

Since this will be fixed by basing the snap on core22, tagging this snap to make it less likely that this will get missed.

tags: added: snap
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.