apache/beam · error
Unknown write type
Error message
Unknown write type %v
What it means
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.
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.
Example fix
// before
req := &fnpb.StateRequest{WriteType: unknownType}
// after
w := channel.NewStateWriter(key, window)
w.Append(ctx, value) Defensive patterns
Strategy: validation
Validate before calling
switch r.writeType {
case channel.Append, channel.Clear:
// ok
default:
return fmt.Errorf("unsupported write type %v", r.writeType)
} Prevention
- Use the public StateWriter Append/Clear APIs
- Never build fnpb StateRequests by hand
- Keep SDK and runner versions aligned when new state opcodes ship
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- failed to decode special type, unknown type
- instruction no longer processing
- invalid bundle processing state
- bad coder kind
- bad CoGBK
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/b17077de25aaeda5.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/runtime/harness/statemgr.go:582
InstructionId: string(r.instID),
StateKey: r.key,
Request: &fnpb.StateRequest_Append{
Append: &fnpb.StateAppendRequest{
Data: toSend,
},
},
}
case writeTypeClear:
req = &fnpb.StateRequest{
// ID: set by StateChannel
InstructionId: string(r.instID),
StateKey: r.key,
Request: &fnpb.StateRequest_Clear{
Clear: &fnpb.StateClearRequest{},
},
}
default:
return 0, errors.Errorf("Unknown write type %v", r.writeType)
}
_, err := localChannel.Send(req)
if err != nil {
return 0, err
}
return len(toSend), nil
}
// StateChannelManager manages data channels over the State API. A fixed number of channels
// are generally used, each managing multiple logical byte streams. Thread-safe.
type StateChannelManager struct {
ports map[string]*StateChannel
mu sync.Mutex
}
// Open opens a R/W StateChannel over the given port.
func (m *StateChannelManager) Open(ctx context.Context, port exec.Port) (*StateChannel, error) {View on GitHub (pinned to 12126d8942)