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 KeyError exception for LastTaskResult #66441

Open
hurzhurz opened this issue Apr 26, 2024 · 0 comments
Open

[BUG] win_task KeyError exception for LastTaskResult #66441

hurzhurz opened this issue Apr 26, 2024 · 0 comments
Labels
Bug broken, incorrect, or confusing behavior

Comments

@hurzhurz
Copy link
Contributor

Description
High result/error codes numbers are return negative numbers by and so not found in the results lookup dict:

results = {
0x0: "The operation completed successfully",
0x1: "Incorrect or unknown function called",
0x2: "File not found",
0xA: "The environment is incorrect",
0x41300: "Task is ready to run at its next scheduled time",
0x41301: "Task is currently running",
0x41302: "Task is disabled",
0x41303: "Task has not yet run",
0x41304: "There are no more runs scheduled for this task",
0x41306: "Task was terminated by the user",
0x8004130F: "Credentials became corrupted",
0x8004131F: "An instance of this task is already running",
0x800710E0: "The operator or administrator has refused the request",
0x800704DD: "The service is not available (Run only when logged in?)",
0xC000013A: "The application terminated as a result of CTRL+C",
0xC06D007E: "Unknown software exception",
}

This leads to exceptions, for example:

                File "C:\salt\var\cache\salt\minion\extmods\modules\win_task.py", line 1478, in info
                  "last_run_result": results[task.LastTaskResult],
              KeyError: -2147020576

-2147020576 would be 0x800710E0 and so "The operator or administrator has refused the request".

Also result codes that are not yet in the lookup dict lead to similar exceptions instead of showing a useful text.

      File "C:\salt\var\cache\salt\minion\extmods\modules\win_task.py", line 1477, in info
        "last_run_result": results[task.LastTaskResult],
    KeyError: 1073807364

Better would be to simply show the result code in such cases (here: "0x40010004").

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
Projects
None yet
Development

No branches or pull requests

2 participants