saltstack / saltstack/salt

[BUG] shortcut.present not idempotent, icon_location still broken

Open
#64,190 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage Windows
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

file.shortcut was broken (see #53706)
The bug was closed as fixed with PR #62025

I migrated stuff to use the new shortcut.present and it's failing badly.

Simple test state:

test_user_shortcut:
  shortcut.present:
    - name: 'C:\Users\someuser\Desktop\test_user.url'
    - target: 'https://google.com/'
    - icon_location: 'c:\test.ico'

test_public_shortcut:
  shortcut.present:
    - name: 'C:\Users\public\Desktop\test_public.url'
    - target: 'https://yahoo.com/'
    - icon_location: 'c:\test.ico'

To run it, stick a valid icon at c:\test.ico and adjust the c:\users\someuser path to point to your account.
Run the state.

The icons are created, but the icon isn't applied.

Notice the salt output that shows things like the icon target being C:\Program Files\Salt Project\Salt\https:\yahoo.com and yet if you right-click the icon and go to 'properties' it points to https://yahoo.com and works properly. Also notice the salt output strips one of the forward slashes from https://.

If you manually set the icon on the 'user' shortcut, it works just fine.
If you try to manually set the icon on the 'public' shortcut, it errors out with: "Cannot apply changes to this Internet Shortcut".

Running the state again produces an error:
Failed to create the shortcut: C:\Users\public\Desktop\test_public.url Found existing shortcut

It shouldn't be an error that the shortcut exists, just like...say....file.managed doesn't error out on the state application because it created the file during the first run.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Windows state using shortcut.present with the two .url paths and a valid icon at c:\test.ico. Start by locating the shortcut.present implementation and compare its first and repeated runs, including icon_location handling. Done means existing shortcuts do not fail on reapplication, the target remains intact, and the icon is applied correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.