Skip to content

ue4 build-target crashes when not specifying any target #66

@sleeptightAnsiC

Description

@sleeptightAnsiC

Running ue4 build-target without giving any argument causes a crash:

╰─$ ue4 build-target
Traceback (most recent call last):
  File "/usr/bin/ue4", line 33, in <module>
    sys.exit(load_entry_point('ue4cli==0.0.54', 'console_scripts', 'ue4')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ue4cli/cli.py", line 222, in main
    SUPPORTED_COMMANDS[command]['action'](manager, args)
  File "/usr/lib/python3.11/site-packages/ue4cli/cli.py", line 54, in <lambda>
    'action': lambda m, args: m.buildTarget(args.pop(0), args.pop(0) if (len(args) > 0) else 'Development', args),
                                            ^^^^^^^^^^^
IndexError: pop from empty list

This is happening because some commands detect arguments with following condition: len(args) > 0 Said condition will always evaluate to True because Python always takes script directory as the first argument. We can easily change len(args) > 0 to len(args) > 1 and this should be resolved for most cases. However, when I was testing it, seems like not every function related to this issue would fail as I was expecting it, e.g. ue4 version works just fine, so it's worth investigating what's going on under the hood before fixing it.

EDIT: No, I was wrong about it. The problem is super simple. We do args.pop(0) without checking if args contains anything which is clearly mentioned in callstack :D

Leaving this one for myself, should be quick to fix.

Reference:

ue4cli/ue4cli/cli.py

Lines 52 to 56 in fed71c1

'build-target': {
'description': 'Build the specified target using UBT',
'action': lambda m, args: m.buildTarget(args.pop(0), args.pop(0) if (len(args) > 0) else 'Development', args),
'args': '<TARGET> [CONFIGURATION]'
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions