{"record":{"id":"0ab0c0896804c9ee","repo":"apache/beam","slug":"cannot-create-s-from-non-java-s-s","errorCode":null,"errorMessage":"Cannot create %s from non-Java %s: %s","messagePattern":"Cannot create (.+?) from non-Java (.+?): (.+?)","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/ParDoTranslation.java","lineNumber":680,"sourceCode":"                .build();\n          }\n        });\n  }\n\n  @VisibleForTesting\n  static StateSpec<?> fromProto(RunnerApi.StateSpec stateSpec, RehydratedComponents components)\n      throws IOException {\n    switch (stateSpec.getSpecCase()) {\n      case READ_MODIFY_WRITE_SPEC:\n        return StateSpecs.value(\n            components.getCoder(stateSpec.getReadModifyWriteSpec().getCoderId()));\n      case BAG_SPEC:\n        return StateSpecs.bag(components.getCoder(stateSpec.getBagSpec().getElementCoderId()));\n      case COMBINING_SPEC:\n        FunctionSpec combineFnSpec = stateSpec.getCombiningSpec().getCombineFn();\n\n        if (!combineFnSpec.getUrn().equals(CombineTranslation.JAVA_SERIALIZED_COMBINE_FN_URN)) {\n          throw new UnsupportedOperationException(\n              String.format(\n                  \"Cannot create %s from non-Java %s: %s\",\n                  StateSpec.class.getSimpleName(),\n                  Combine.CombineFn.class.getSimpleName(),\n                  combineFnSpec.getUrn()));\n        }\n\n        Combine.CombineFn<?, ?, ?> combineFn =\n            (Combine.CombineFn<?, ?, ?>)\n                SerializableUtils.deserializeFromByteArray(\n                    combineFnSpec.getPayload().toByteArray(),\n                    Combine.CombineFn.class.getSimpleName());\n\n        // Rawtype coder cast because it is required to be a valid accumulator coder\n        // for the CombineFn, by construction\n        return StateSpecs.combining(\n            (Coder) components.getCoder(stateSpec.getCombiningSpec().getAccumulatorCoderId()),\n            combineFn);","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/ParDoTranslation.java#L662-L698","documentation":"When translating a RunnerApi StateSpec back into a Java StateSpec, a COMBINING spec must carry a combine FunctionSpec with the Java serialized combine fn URN (beam:combine_fn:java_serialized:v1). Any other URN means the combine function is not a Java-serializable one, so Beam cannot reconstruct a Java CombineFn and throws this UnsupportedOperationException.","triggerScenarios":"Calling ParDoTranslation.stateSpecFromProto (via graph translation) on a state spec whose combining spec references a combine fn URN other than JAVA_SERIALIZED_COMBINE_FN_URN — e.g. a portably-encoded/custom combine fn produced by another SDK or expansion service.","commonSituations":"Cross-language pipelines where a Python/Go transform defines stateful combining; using an expansion service that emits portable combine URNs; mixing Beam versions where combine fn encoding differs.","solutions":["Ensure the state spec's combine fn is defined in Java and serialized via CombineTranslation's Java serialized URN","Avoid Java-specific state/combine translation for portable graphs; use runner-side portable handling instead of ParDoTranslation","Regenerate the pipeline proto so Java-side DoFns are encoded with the serialized Java combine fn"],"exampleFix":"// before\nFunctionSpec combineFnSpec = FunctionSpec.newBuilder().setUrn(\"beam:combine_fn:custom:v1\").build();\n// after\nFunctionSpec combineFnSpec = CombineTranslation.combineFnToSpec(Sum.ofIntegers()); // uses JAVA_SERIALIZED_COMBINE_FN_URN","handlingStrategy":"validation","validationCode":"FunctionSpec spec = stateSpec.getCombiningSpec().getCombineFn();\nif (!CombineTranslation.JAVA_SERIALIZED_COMBINE_FN_URN.equals(spec.getUrn())) throw new IllegalArgumentException(\"non-Java combine fn: \" + spec.getUrn());","typeGuard":"boolean isJavaSerializedCombineFn(FunctionSpec s) { return s != null && CombineTranslation.JAVA_SERIALIZED_COMBINE_FN_URN.equals(s.getUrn()); }","tryCatchPattern":"try { StateSpec<?> s = ParDoTranslation.stateSpecFromProto(stateSpec, components); } catch (UnsupportedOperationException e) { /* fall back to portable translation path */ }","preventionTips":["Use Java CombineFn subclasses for stateful Java DoFns","Avoid mixing SDK-defined combining state across languages","Verify pipeline protos' FunctionSpec URNs before Java-side translation"],"tags":["java","apache-beam","pardo","state-api","cross-language"],"backgroundTag":"unsupported-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"}