ARTIFACTORY: How to solve the error "Checksum Policy 'GEN_IF_ABSENT' Rejected the Artifact"

Products
Frog_Artifactory
Content Type
Use_Case
AuthorFullName__c
Yunzong Guo
articleNumber
000006801
FirstPublishedDate
2025-12-29T08:34:44Z
lastModifiedDate
2025-12-29

ARTIFACTORY: How to solve the error "Checksum Policy 'GEN_IF_ABSENT' Rejected the Artifact"

Description 

Sometimes, when executing "npm install <package>", even if the client user has read and write permissions to the npm remote repository, you may still encounter a 403 error and cause package resolution to fail (such as "npm install @babel/plugin-syntax-dynamic-import"). 

The error message  "Checksum policy 'GEN_IF_ABSENT' rejected the artifact"  could be found in artifactory-service.log :
2025-12-22T08:16:58:086Z [jfrt ] [ERROR] [daeb3c4fff8d4f52] [o.a.r.HttpRepo:1371    ] [-nio-8081-exec-64893] - npm-remote: Failed to download 'https://mirrors.xxx.cloud.com/repository/npm/@babel%2Fplugin-syntax-dynamic-import'. Received status code 200 and caught exception: Checksum policy 'GEN_IF_ABSENT' rejected the artifact 'npm-remote:.npm/@babel/plugin-syntax-dynamic-import/package.json'. Checksums info: ChecksumsInfo{checksums={SHA-1=ChecksumInfo{type=SHA-1}, original='57f718629854aa15667c7a80bea17771c62b4fd3', actual='b3d0c180a0a139a4b708721bb68c874b4937dfb0'}...
This issue occurs because the npm remote address returns an incorrect SHA1 checksum, which is inconsistent with the checksum generated by Artifactory, and Artifactory rejects caching this package due to the default "Checksum Policy".

How to solve this issue?


Solution


The default "Checksum Policy" for npm remote repositories is "Generate if absent," meaning that if the remote checksum does not match the locally calculated checksum, the artifact will not be cached and the download will fail.

You can change the remote repository configuration parameter "remoteRepoChecksumPolicyType" from the default "generate-if-absent" to "pass-thru" (The system stores and passes through all remote checksums, even if they do not match the locally generated one).

1. Execute the following API (for example: the remote repository named "npm-remote"):
curl -XPOST -uadmin:password "http://<artifactory_url>/artifactory/api/repositories/npm-remote" -H "content-type: application/json" -d '{"remoteRepoChecksumPolicyType": "pass-thru"}'
2. Then, execute "npm install " again and you can resolve the npm package successfully.


Reference

https://jfrog.com/help/r/jfrog-rest-apis/update-repository-configuration

https://jfrog.com/help/r/jfrog-rest-apis/repository-configuration-json