apache/beam · error

request has unexpected type %T

Error message

request has unexpected type %T

What it means

stageFiles returns this when the streaming request from the artifact service is neither an ArtifactRequest nor another recognized oneof member, hitting the outer default case. It indicates a malformed or unknown message type on the staging stream.

Solutions

  1. Align Beam Go SDK and job server versions
  2. Verify the artifact endpoint actually hosts a Beam ArtifactStagingService
  3. Capture the %T type in the error and compare against the current JobApi protobuf definitions
  4. Retry staging after upgrading; if persistent, file an issue with the type name

Example fix

// before
default:
  return errors.Errorf("request has unexpected type %T", request)
// after: upgrade SDK/job server to matching versions so the oneof shapes line up, then resubmit
Defensive patterns

Strategy: type-guard

Type guard

func isKnownStagingResponse(resp *jobpb.ReverseArtifactRetrievalServiceResponse) bool {
  return resp.GetArtifact() != nil // oneof member the SDK can handle
}

Try / catch

if err := submit(...); err != nil && strings.Contains(err.Error(), "request has unexpected type ") {
  // %T in err names the unknown message type: fix version skew
}

Prevention

When it happens

Trigger: stream.Recv() yields a ReverseArtifactRetrievalServiceResponse whose oneof is not GetArtifact — protocol incompatibility or a corrupted/garbage response from the server.

Common situations: SDK/JobService protobuf version mismatch (server sends message shapes the client's generated code doesn't recognize), or a non-Beam service on the artifact endpoint.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/272e744fd3df815a. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/runners/universal/runnerlib/stage.go:138

				}
			case graphx.URNArtifactFileType:
				typePl := pipepb.ArtifactFilePayload{}
				if err := proto.Unmarshal(request.GetArtifact.Artifact.TypePayload, &typePl); err != nil {
					return errors.Wrap(err, "failed to parse artifact file payload")
				}
				if err := stageFile(typePl.GetPath(), stream); err != nil {
					if err == io.EOF {
						continue // so we can get the real error from stream.Recv.
					}
					return errors.Wrapf(err, "failed to stage file %v", typePl.GetPath())

				}
			default:
				return errors.Errorf("request has unexpected artifact type %s", typeUrn)
			}

		default:
			return errors.Errorf("request has unexpected type %T", request)
		}
	}
}

func stageFile(filename string, stream jobpb.ArtifactStagingService_ReverseArtifactRetrievalServiceClient) error {
	fd, err := os.Open(filename)
	if err != nil {
		return errors.Wrapf(err, "unable to open file %v", filename)
	}
	defer fd.Close()

	data := make([]byte, 1<<20)
	for {
		n, err := fd.Read(data)
		if n > 0 {
			sendErr := stream.Send(&jobpb.ArtifactResponseWrapper{
				Response: &jobpb.ArtifactResponseWrapper_GetArtifactResponse{
					GetArtifactResponse: &jobpb.GetArtifactResponse{

View on GitHub (pinned to 12126d8942)