Gvm-script | Modify task fails on update-task-target.gmp.py

GVM versions

gsad: (Greenbone Security Assistant 21.4.3)
gvmd: (Greenbone Vulnerability Manager 21.4.4)
openvas-scanner: (OpenVAS 21.4.3)
gvm-libs: (gvm-libs 21.4.3)

Environment

Operating system:
NAME=“Ubuntu”
VERSION=“20.04.4 LTS (Focal Fossa)”
Kernel: ('Linux 5.13.0-1017-aws #19~20.04.1-Ubuntu SMP Mon Mar 7 12:53:12 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux)
Installation method / source:
Docker

I’m trying to update the targets of a task using update-task-target.gmp.py. It creates the target successfully as a copy, but fails to update the task with the new target id. The error message returned is “Response Error 400. Status must be New to edit Target”

It looks like neither of these functions get run:

def create_target_hosts(gmp: Gmp, host_file, task_id, old_target_id):
    new_target_id = copy_send_target(gmp, host_file, old_target_id)

    gmp.modify_task(task_id=task_id, target_id=new_target_id)

    print('  Task successfully modified!\n')


def check_to_delete(gmp: Gmp, target_id: str) -> None:
    target = gmp.get_target(target_id=target_id)[0]
    if '0' in target.xpath("in_use/text()"):
        gmp.delete_target(target_id=target_id)

Is there a way around this? I’m simply trying to have a task named “monthly scan” and update the targets to the task monthly and rescan. This way I can keep previous reports and rerun the same tasks with new updated targets. It looks as though the status of the task needs to be “New”. Is there a way to get around this?