jenkinsapi icon indicating copy to clipboard operation
jenkinsapi copied to clipboard

Fingerprint validation fails when artifacts have different filenames but same contents/hash

Open gjb1002 opened this issue 5 years ago • 7 comments

ISSUE TYPE
  • Bug Report
Jenkinsapi 0.3.9
Jenkins 2.150.2
SUMMARY

If I do "Replay" from a pipeline build it confuses the fingerprint handling code, frequently leading to errors when the fingerprints are perfectly correct. This seems to be because the new artifact has the same content and hence md5sum but a different file name (our artifact has a timestamp in its name), leading to the "original" structure having the wrong data.

EXPECTED RESULTS

Fingerprints should match correctly.

ACTUAL RESULTS

jenkinsapi.custom_exceptions.ArtifactBroken: Artifact c95cdb45923926b28833833b770770e1 seems to be broken, check <jenkins url>

In log

Filename from jenkins (<artifact name from original build>) did not match provided (<artifact name from replayed build>)

gjb1002 avatar May 24 '19 14:05 gjb1002

A key question is what purpose the filename check that leads to this error in the "validate_for_build" method in fingerprint.py actually serves?

if self._data["fileName"] != filename:

What can actually lead to this error being emitted correctly, other than internal errors in Jenkins?

gjb1002 avatar May 27 '19 09:05 gjb1002

The same problem, and still not work for save

artifact.save(fspath(path), False)

wulinjie122 avatar Jun 12 '19 03:06 wulinjie122

What is the use case in your code?

Fingerprints are found by MD5 and first file that has this fingerprint will be referred via "fileName" attribute and this is current check. At the same time, the list of all files with the same fingerprint is returned. This is not currently checked. Do you want check to be made that your file is in that list?

lechat avatar Jun 15 '19 05:06 lechat

I want it to work :) The only thing I have that is at all unusual is that several files have different names but the same MD5. This leads to the error above if I enable fingerprints and try to save artifacts via jenkinsapi.

I don't really see the point of the check, so I would be happy for it to be removed, but keeping track of all the files with a certain MD5 and checking that the file is in the list would also work I guess.

gjb1002 avatar Jun 18 '19 10:06 gjb1002

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 18 '19 17:10 stale[bot]

@gjb1002 I too have experienced this issue where I have one original file and another with a timestamp appended too it. I don't see the importance of checking the file name during the verification process in fingerprint, but if it is to remain I think checking all file names that have a matching MD5 and return true on a single match instance would be a reasonable fix.

Edit software versions

python: 2.7.16 jenkinsapi: 0.3.9 Jenkins: 2.183

dtgraham9 avatar Dec 05 '19 18:12 dtgraham9

This was reported as issue #430. I came across this failure as well. I find that verifying the filename is useless due to the way Jenkins allows multiple artifacts to be identical yet have different names. I have submitted PR-851.

plastikos avatar Dec 14 '23 19:12 plastikos