{"record":{"id":"7e925f99ee610ee2","repo":"apache/beam","slug":"unable-to-infer-a-coder-for-multimapstate-and-no-coder-was","errorCode":null,"errorMessage":"Unable to infer a coder for MultimapState and no Coder was specified. Please set a coder by either invoking StateSpecs.multimap(Coder<K> keyCoder, Coder<V> valueCoder) or by registering the coder in the Pipeline's CoderRegistry.","messagePattern":"Unable to infer a coder for MultimapState and no Coder was specified\\. Please set a coder by either invoking StateSpecs\\.multimap\\(Coder<K> keyCoder, Coder<V> valueCoder\\) or by registering the coder in the Pipeline's CoderRegistry\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/state/StateSpecs.java","lineNumber":830,"sourceCode":"    public <ResultT> ResultT match(Cases<ResultT> cases) {\n      return cases.dispatchMultimap(keyCoder, valueCoder);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public void offerCoders(Coder[] coders) {\n      if (this.keyCoder == null && coders[0] != null) {\n        this.keyCoder = (Coder<K>) coders[0];\n      }\n      if (this.valueCoder == null && coders[1] != null) {\n        this.valueCoder = (Coder<V>) coders[1];\n      }\n    }\n\n    @Override\n    public void finishSpecifying() {\n      if (keyCoder == null || valueCoder == null) {\n        throw new IllegalStateException(\n            \"Unable to infer a coder for MultimapState and no Coder\"\n                + \" was specified. Please set a coder by either invoking\"\n                + \" StateSpecs.multimap(Coder<K> keyCoder, Coder<V> valueCoder) or by registering\"\n                + \" the coder in the Pipeline's CoderRegistry.\");\n      }\n    }\n\n    @Override\n    public boolean equals(@Nullable Object obj) {\n      if (obj == this) {\n        return true;\n      }\n\n      if (!(obj instanceof MultimapStateSpec)) {\n        return false;\n      }\n\n      MultimapStateSpec<?, ?> that = (MultimapStateSpec<?, ?>) obj;","sourceCodeStart":812,"sourceCodeEnd":848,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/state/StateSpecs.java#L812-L848","documentation":"A MultimapState spec created without key and/or value coders cannot infer both at finishSpecifying time. MultimapStateSpec.finishSpecifying() throws IllegalStateException when keyCoder or valueCoder is null.","triggerScenarios":"Calling StateSpecs.multimap() (no-arg overload) where inference fails for the key type K or the value type V.","commonSituations":"Multimaps with custom key or value classes lacking registered coders; specs converted from map specs via convertToMultimapSpec where coders were never supplied.","solutions":["Pass both coders: StateSpecs.multimap(keyCoder, valueCoder).","Register coders for K and V in the pipeline's CoderRegistry.","If converting from a MapStateSpec, ensure the original map spec had explicit coders."],"exampleFix":"// before\nMultimapStateSpec<String, Long> spec = StateSpecs.multimap();\n// after\nMultimapStateSpec<String, Long> spec = StateSpecs.multimap(StringUtf8Coder.of(), VarLongCoder.of());","handlingStrategy":"validation","validationCode":"if (keyCoder == null || valueCoder == null) {\n  throw new IllegalStateException(\"Supply StateSpecs.multimap(keyCoder, valueCoder) with explicit coders\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  spec = StateSpecs.multimap();\n} catch (IllegalStateException e) {\n  if (e.getMessage().contains(\"MultimapState\")) {\n    spec = StateSpecs.multimap(keyCoder, valueCoder);\n  } else throw e;\n}","preventionTips":["Always pass both key and value coders to StateSpecs.multimap()","Ensure converted map specs carry explicit coders","Register coders for K and V in the CoderRegistry"],"tags":["java","apache-beam","state","coder-inference"],"backgroundTag":"missing-required-config","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"}