You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Blocked by #63 - This PR must be merged/rejected before attempting the fix, as it touches the same code and also uses len(args) > 0 condition in few places.
I just randomly found a logical error for ue4 build-target
Editing the issue
sleeptightAnsiC
changed the title
cli.py SUPPORTED_COMMANDS (len(args) > 0) always evaluates to Trueue4 build-target crashes when not specifying any target
Mar 23, 2024
Running
ue4 build-target
without giving any argument causes a crash:This is happening because some commands detect arguments with following condition:len(args) > 0
Said condition will always evaluate toTrue
because Python always takes script directory as the first argument. We can easily changelen(args) > 0
tolen(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 ifargs
contains anything which is clearly mentioned in callstack :DLeaving this one for myself, should be quick to fix.
Reference:
ue4cli/ue4cli/cli.py
Lines 52 to 56 in fed71c1
The text was updated successfully, but these errors were encountered: