fix(artifacts): support upload-artifact@v7 / download-artifact@v8#6115
Open
royteeuwen wants to merge 1 commit into
Open
fix(artifacts): support upload-artifact@v7 / download-artifact@v8#6115royteeuwen wants to merge 1 commit into
royteeuwen wants to merge 1 commit into
Conversation
The v4 artifact server rejected requests from newer @actions/upload-artifact releases for two independent reasons: 1. parseProtbufBody used a strict protojson.Unmarshal, which fails on any field absent from act's vendored protobuf. upload-artifact@v7 adds a `mime_type` field to the artifact requests, producing `Error decode request body: unknown field "mime_type"`. Decoding with DiscardUnknown ignores fields act doesn't consume and keeps the server forward-compatible with future optional additions. 2. verifySignature decoded the `sig` query parameter with base64.URLEncoding, which requires `=` padding. The Azure storage SDK used by upload-artifact@v7 for blob upload strips the padding when it re-serializes the signed URL to append comp/blockid, so the strict decode failed silently and the HMAC check rejected the upload with `Error unauthorized`. Decoding with RawURLEncoding after trimming any `=` accepts both the padded (v4-era) and unpadded (v7+) forms. Both changes only relax parsing, so older clients are unaffected; verified end-to-end with v4<->v4 and v7<->v8 upload/download round-trips. Adds regression tests for both cases. Signed-off-by: Roy Teeuwen <roy@teeuwen.be>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6114.
The v4 artifact server rejected uploads from
actions/upload-artifact@v7(and the matchingdownload-artifact@v8) for two independent reasons. Both are narrow, backward-compatible relaxations of request parsing.1.
unknown field "mime_type"parseProtbufBodyused a strictprotojson.Unmarshal, which fails on any field absent from act's vendored protobuf.upload-artifact@v7adds amime_typefield, producingError decode request body: unknown field "mime_type"atCreateArtifact.Decoding with
protojson.UnmarshalOptions{DiscardUnknown: true}ignores fields act doesn't consume and keeps the server forward-compatible with future optional additions.2.
Error unauthorizedverifySignaturedecoded thesigquery parameter withbase64.URLEncoding, which requires=padding. The Azure storage SDK used byupload-artifact@v7for blob upload strips the padding when it re-serializes the signed URL to appendcomp/blockid, so the strict decode failed silently and the HMAC check rejected the upload.Decoding with
base64.RawURLEncodingafter trimming any=accepts both the padded (v4-era) and unpadded (v7+) forms.Compatibility
Both changes only relax parsing — they never reject anything the previous code accepted, so v4/v5/v6 clients are unaffected. (
upload-artifact@v1–v3use a separate, non-protobuf code path that this change does not touch.)Testing
TestCreateArtifactV4IgnoresUnknownFieldsandTestUploadArtifactV4AcceptsUnpaddedSignature.go test ./pkg/artifacts/passes.upload-artifact@v4→download-artifact@v4, andupload-artifact@v7→download-artifact@v8, both round-trip successfully (including a ~160 MB artifact).