{"record":{"id":"b17077de25aaeda5","repo":"apache/beam","slug":"unknown-write-type-v","errorCode":null,"errorMessage":"Unknown write type %v","messagePattern":"Unknown write type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/harness/statemgr.go","lineNumber":582,"sourceCode":"\t\t\tInstructionId: string(r.instID),\n\t\t\tStateKey:      r.key,\n\t\t\tRequest: &fnpb.StateRequest_Append{\n\t\t\t\tAppend: &fnpb.StateAppendRequest{\n\t\t\t\t\tData: toSend,\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\tcase writeTypeClear:\n\t\treq = &fnpb.StateRequest{\n\t\t\t// ID: set by StateChannel\n\t\t\tInstructionId: string(r.instID),\n\t\t\tStateKey:      r.key,\n\t\t\tRequest: &fnpb.StateRequest_Clear{\n\t\t\t\tClear: &fnpb.StateClearRequest{},\n\t\t\t},\n\t\t}\n\tdefault:\n\t\treturn 0, errors.Errorf(\"Unknown write type %v\", r.writeType)\n\t}\n\n\t_, err := localChannel.Send(req)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn len(toSend), nil\n}\n\n// StateChannelManager manages data channels over the State API. A fixed number of channels\n// are generally used, each managing multiple logical byte streams. Thread-safe.\ntype StateChannelManager struct {\n\tports map[string]*StateChannel\n\tmu    sync.Mutex\n}\n\n// Open opens a R/W StateChannel over the given port.\nfunc (m *StateChannelManager) Open(ctx context.Context, port exec.Port) (*StateChannel, error) {","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/harness/statemgr.go#L564-L600","documentation":"StateWriter.Write switches on the request's writeType (append/clear); any other value hits the default branch and fails. This indicates an internal enum/type mismatch when constructing a state write request in the Beam Go harness.","triggerScenarios":"Invoking state writing machinery with a StateRequest whose writeType was not Append or Clear — effectively only from internal/runtime code paths or a struct initialized with a zero/unknown write type.","commonSituations":"Beam runtime bugs after adding a new write type without updating Write, hand-built fnpb state requests in tests or forks, zero-valued request structs passed to Write.","solutions":["Only use the public Append/Clear APIs rather than constructing StateWriterRequest directly.","Update the Beam Go SDK; if a new write type is unhandled, it is a version-skew bug between runner and SDK.","If in a fork, add a case for the new write type in StateWriter.Write before the default branch.","Check that request structs are fully initialized, not zero-valued."],"exampleFix":"// before\nreq := &fnpb.StateRequest{WriteType: unknownType}\n// after\nw := channel.NewStateWriter(key, window)\nw.Append(ctx, value)","handlingStrategy":"validation","validationCode":"switch r.writeType {\ncase channel.Append, channel.Clear:\n    // ok\ndefault:\n    return fmt.Errorf(\"unsupported write type %v\", r.writeType)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the public StateWriter Append/Clear APIs","Never build fnpb StateRequests by hand","Keep SDK and runner versions aligned when new state opcodes ship"],"tags":["go","beam","state-management","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}