Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] win_task.py delete_after=False throws Invalid value for "delete_after" #63650

Closed
amalaguti opened this issue Feb 6, 2023 · 0 comments
Closed
Labels
Bug broken, incorrect, or confusing behavior needs-triage Windows

Comments

@amalaguti
Copy link

Description
Windows Minion trying to use win_task.py module to edit a Task Scheduler task, changing delete_after to False, throws
"Invalid value for "delete_after""

Setup
Windows Minion 3004.2

Steps to Reproduce the behavior
Create a Task in Task Scheduler with a trigger and setting delete_after=Immediately (or XX days), under Settings > "If the task is not scheduled to run again, delete it after:"

>salt-call --local task.edit_task "Task Name" location="\Salt" delete_after=False
local:
    Invalid value for "delete_after"

Expected behavior
The setting should be cleared

Screenshots
If applicable, add screenshots to help explain your problem.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
PASTE HERE

Additional context
Add any other context about the problem here.

Possible fix:
Around these lines I did a quick fix
https://github.com/saltstack/salt/blob/master/salt/modules/win_task.py#L1128-L1137

if delete_after is not None:
      # TODO: Check triggers for end_boundary
    if delete_after is False:
        task_definition.Settings.DeleteExpiredTaskAfter = ""
    # Added else 
    else:
        if delete_after in duration:
            task_definition.Settings.DeleteExpiredTaskAfter = _lookup_first(duration, delete_after)
        else:
            return 'Invalid value for "delete_after"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage Windows
Projects
None yet
Development

No branches or pull requests

3 participants