Skip to content

fix: discard unknown fields in protobuf unmarshal for artifact v4 API#6039

Open
majiayu000 wants to merge 2 commits intonektos:masterfrom
majiayu000:fix/issue-6022-artifact-discard-unknown-fields
Open

fix: discard unknown fields in protobuf unmarshal for artifact v4 API#6039
majiayu000 wants to merge 2 commits intonektos:masterfrom
majiayu000:fix/issue-6022-artifact-discard-unknown-fields

Conversation

@majiayu000
Copy link
Copy Markdown

Fixes #6022

Summary

upload-artifact@v7 sends new fields (e.g. mime_type) in CreateArtifact requests that are not in the proto definition (artifact.pb.go). The default strict protojson.Unmarshal rejects these, causing a 500 error.

This changes parseProtbufBody in pkg/artifacts/artifacts_v4.go to use protojson.UnmarshalOptions{DiscardUnknown: true}, which silently ignores unknown fields. This is the standard approach for forward-compatible protobuf handling.

Changes

  • pkg/artifacts/artifacts_v4.go: Use UnmarshalOptions{DiscardUnknown: true} instead of plain protojson.Unmarshal
  • pkg/artifacts/server_test.go: Add unit test verifying CreateArtifact succeeds when request contains unknown fields

Test Plan

  • go test ./pkg/artifacts/... passes
  • New test TestCreateArtifactWithUnknownFields sends a request body with an extra mime_type field and asserts HTTP 200

upload-artifact@v7 sends a mime_type field in CreateArtifact requests
that is not defined in the proto schema, causing strict unmarshalling
to fail. Use protojson.UnmarshalOptions{DiscardUnknown: true} to
silently ignore unknown fields, which is the standard approach for
forward-compatible protobuf handling.

Fixes nektos#6022

Signed-off-by: majiayu000 <1835304752@qq.com>
Verify that the CreateArtifact v4 endpoint correctly handles request
bodies containing unknown protobuf fields (e.g. mime_type sent by
upload-artifact@v7) by returning HTTP 200 instead of 500.

Signed-off-by: majiayu000 <1835304752@qq.com>
@majiayu000 majiayu000 marked this pull request as ready for review March 25, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Artifact server: CreateArtifact fails with unknown field "mime_type" for upload-artifact@v7

1 participant