Repository navigation
fix: skip S3 existence check to unblock sbt +publish (job 153) - #34
circleci-app[bot] wants to merge 1 commit into
Conversation
The `sbt +publish` step was failing with S3 403 Forbidden because `fm-sbt-s3-resolver` calls `getObjectMetadata` (a HEAD request) to check if an artifact already exists before uploading. The IAM policy attached to the CodacyAWS credentials permits s3:PutObject but not s3:GetObject/s3:HeadObject on private.mvn.codacy.com, so the pre-check returns 403 and aborts the entire publish before any upload is attempted. Setting `overwrite := true` in publishConfiguration tells Ivy to skip the existence check (URLRepository.put line 74 `if (!overwrite)` block) and proceed directly to the PUT, which the credentials are authorised to perform. AI-Generated: true
Up to standards ✅🟢 Issues
|
There was a problem hiding this comment.
Pull Request Overview
The proposed global overwrite behavior can replace existing S3 artifacts, creating non-reproducible releases and publish races. Scope overwrite to an explicit CI/job-153 opt-in while keeping normal publishes protected.
All required publish verification scenarios are missing, and the publish configuration has no automated coverage. Codacy reports the PR as up to standards.
About this PR
- Add automated or CI-level verification for the publish configuration and confirm the uploaded artifact is present at the expected S3 path.
Test suggestions
- Verify remote publish uses overwrite=true and does not perform the S3 metadata/existence check before uploading.
- Verify publishLocal uses overwrite=true.
- Run the publish job and confirm the artifact is uploaded to the expected S3 path.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify remote publish uses overwrite=true and does not perform the S3 metadata/existence check before uploading.
2. Verify publishLocal uses overwrite=true.
3. Run the publish job and confirm the artifact is uploaded to the expected S3 path.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
| publishConfiguration := publishConfiguration.value.withOverwrite(true) | ||
| publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true) |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Scope overwrite to the specific CI job or an explicit opt-in property, while retaining the default protection against replacing existing remote artifacts.
Problem
Job 153 (
publish) failed atsbt +publishwith:fm-sbt-s3-resolvercallsgetObjectMetadata(an S3HEADrequest) to check whether an artifact already exists before uploading. The IAM permissions attached to theCodacyAWScontext allows3:PutObjectonprivate.mvn.codacy.combut nots3:GetObject/s3:HeadObject, so the pre-flight existence check returns 403 and aborts the publish before any actual upload is attempted.This regressed in #33, which was the first time this project published to the private S3 Maven repo (previously it published to Sonatype Central).
Fix
Add
publishConfiguration := publishConfiguration.value.withOverwrite(true)tobuild.sbt. This sets theoverwriteflag that Ivy passes intoURLRepository.put. Whenoverwrite = true, theif (!overwrite)block at line 74 is skipped entirely — nogetObjectMetadatacall, no 403. The actualPutObjectupload then proceeds with the credentials that are authorised to write.publishLocalConfigurationis updated in parallel for consistency with localpublishLocalinvocations.Test plan
publishjob in CI passes after this changes3://private.mvn.codacy.comat the expected pathhttps://app.circleci.com/agents/gh/codacy/chat/636cbca8-87a1-4f0a-b502-a2230d6a2943