jfrog-cli icon indicating copy to clipboard operation
jfrog-cli copied to clipboard

Dangling symlinks cause upload errors with wildcards in filespecs

Open creid-arista opened this issue 1 year ago • 4 comments

Describe the bug

When attempting to upload via a filespec that includes a pattern with a wildcard, if the current directory or any child directories contain dangling symlinks the upload will fail. This is regardless of whether or not the dangling symlink matches the pattern.

Current behavior

[Debug] Usage Report: Sending info...
[Debug] Sending HTTP GET request to: .../artifactory/api/system/version
[Error] stat broken.symlink: no such file or directory
[Error] stat broken.symlink: no such file or directory
[Debug] Uploaded 0 artifacts.
[Error] stat broken.symlink: no such file or directory
[Debug] Artifactory response: 200 OK
[Debug] JFrog Artifactory version is: 7.63.10
[Debug] Sending HTTP POST request to: .../artifactory/api/system/usage

Reproduction steps

Create the following structure:

.
├── a-test.txt
├── broken.symlink -> a-file.txt
└── upload.filespec

upload.filespec:

{
    "files": [
        {
            "pattern": "./*-test.txt",
            "target": "generic-test/",
            "props": "name=Test File"
        }
    ]
}

Run jfrog rt u --spec=upload.filespec

Expected behavior

Upload the relevant file and ignore the irrelevant broken symlink.

JFrog CLI version

2.67.0

Operating system type and version

AlmaLinux 9.4

JFrog Artifactory version

No response

JFrog Xray version

No response

creid-arista avatar Sep 10 '24 01:09 creid-arista

Hey. I'm experiencing the same issue. Do we have at least a workaround?

Plonk42 avatar Dec 02 '24 17:12 Plonk42

The only workarounds I've found are to either clean up your broken symlinks prior to trying the upload, or make use of the --symlinks arg, e.g. jfrog rt u --symlinks --spec=upload.filespec. Using --symlinks changes functionality as it now uploads the symlink and not the file the symlink was pointing to.

creid-arista avatar Dec 04 '24 05:12 creid-arista

Thanks. I went with cleaning dangling symlinks before uploading. For reference, here is the command I used: find . -xtype l -exec rm {} +.

ChatGPT breakdown:

  1. find .
    • This initiates a search starting from the current directory (.) and includes all subdirectories.
  2. -xtype l
    • This option filters the search results to broken symbolic links.
    • Broken symbolic links are links pointing to a file or directory that no longer exists.
  3. -exec rm {} +
    • This executes the rm (remove) command on each broken link found.
    • {} is a placeholder that find replaces with the file path of each broken link.
    • + ensures multiple files are passed to rm in a single command, improving efficiency by reducing the number of calls to rm.

Plonk42 avatar Dec 05 '24 15:12 Plonk42

This is still happening on CLI version 2.72.5. It seems the issue was introduced in 2.60.0.

critchtionary avatar Jan 06 '25 16:01 critchtionary

This issue has been marked as stale due to 6 months of inactivity. As part of our effort to address every issue properly, please feel free to remove the stale label or keep this issue active by leaving a comment. Otherwise, it will be closed in 7 days

github-actions[bot] avatar Jul 06 '25 00:07 github-actions[bot]

This issue was closed due to 7 days of inactivity after being marked as stale. Feel free to reopen it if it remains relevant.

github-actions[bot] avatar Jul 13 '25 00:07 github-actions[bot]