You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "Cody Schroeder (JIRA)" <ji...@apache.org> on 2018/05/24 16:34:00 UTC

[jira] [Created] (BEAM-4401) beam.Create fails to encode valid elements

Cody Schroeder created BEAM-4401:
------------------------------------

             Summary: beam.Create fails to encode valid elements
                 Key: BEAM-4401
                 URL: https://issues.apache.org/jira/browse/BEAM-4401
             Project: Beam
          Issue Type: Bug
          Components: sdk-go
            Reporter: Cody Schroeder
            Assignee: Cody Schroeder


The following program will panic because part of the proto3 message cannot be JSON marshalled.

{noformat}
panic: failed to decode data: json: cannot unmarshal object into Go struct field Path_Node.Specialization of type internal_go_proto.isPath_Node_Specialization
{noformat}


{code:go}
package main

import (
	"context"

	"github.com/apache/beam/sdks/go/pkg/beam"
	"github.com/apache/beam/sdks/go/pkg/beam/x/beamx"
	"github.com/apache/beam/sdks/go/pkg/beam/x/debug"

	ipb "kythe.io/kythe/proto/internal_go_proto"
	srvpb "kythe.io/kythe/proto/serving_go_proto"
)

func main() {
	ctx := context.Background()
	beam.Init()

	p := beam.NewPipeline()
	s := p.Root()

	e := &ipb.Path_Node{
		// proto3 oneof fields cannot be JSON marshalled
		Specialization: &ipb.Path_Node_RawAnchor{&srvpb.RawAnchor{}},
	}
	els := beam.Create(s, e)
	debug.Print(s, els)

	if err := beamx.Run(ctx, p); err != nil {
		panic(err)
	}
}
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)