{"record":{"id":"ed436c0595689a38","repo":"apache/beam","slug":"cannot-provide-a-coder-for-type-variable-s-because-the","errorCode":null,"errorMessage":"Cannot provide a coder for type variable %s because the actual type is over specified by multiple incompatible coders %s.","messagePattern":"Cannot provide a coder for type variable (.+?) because the actual type is over specified by multiple incompatible coders (.+?)\\.","errorType":"exception","errorClass":"CannotProvideCoderException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java","lineNumber":619,"sourceCode":"   * use the given coders.\n   *\n   * @throws CannotProvideCoderException if a coder cannot be provided\n   */\n  private <T> Coder<T> getCoderFromTypeDescriptor(\n      TypeDescriptor<T> typeDescriptor, SetMultimap<Type, Coder<?>> typeCoderBindings)\n      throws CannotProvideCoderException {\n    Type type = typeDescriptor.getType();\n    Coder<?> coder;\n    if (typeDescriptor.equals(TypeDescriptors.rows())) {\n      throw new CannotProvideCoderException(\n          \"Cannot provide a coder for a Beam Row. Please provide a schema instead using PCollection.setRowSchema.\");\n    }\n    if (typeCoderBindings.containsKey(type)) {\n      Set<Coder<?>> coders = typeCoderBindings.get(type);\n      if (coders.size() == 1) {\n        coder = Iterables.getOnlyElement(coders);\n      } else {\n        throw new CannotProvideCoderException(\n            String.format(\n                \"Cannot provide a coder for type variable %s\"\n                    + \" because the actual type is over specified by multiple\"\n                    + \" incompatible coders %s.\",\n                type, coders),\n            ReasonCode.OVER_SPECIFIED);\n      }\n    } else if (type instanceof Class<?>) {\n      coder = getCoderFromFactories(typeDescriptor, Collections.emptyList());\n    } else if (type instanceof ParameterizedType) {\n      coder = getCoderFromParameterizedType((ParameterizedType) type, typeCoderBindings);\n    } else if (type instanceof TypeVariable) {\n      coder = getCoderFromFactories(typeDescriptor, Collections.emptyList());\n    } else if (type instanceof WildcardType) {\n      // No coder for an unknown generic type.\n      throw new CannotProvideCoderException(\n          String.format(\"Cannot provide a coder for wildcard type %s.\", type), ReasonCode.UNKNOWN);\n    } else {","sourceCodeStart":601,"sourceCodeEnd":637,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java#L601-L637","documentation":"The type being resolved is a type variable bound in the registry's context to multiple coders, and those coders conflict (over-specified), so no single unambiguous coder can be chosen. getCoderFromTypeDescriptor throws CannotProvideCoderException with ReasonCode.OVER_SPECIFIED. This protects against silently picking one of several incompatible coders for the same type.","triggerScenarios":"getCoder / getDefaultCoders / getCoderFromParameterizedType with a typeCoderBindings multimap where the target type maps to two or more different coders, e.g. the same type variable registered twice with different coders.","commonSituations":"Registering the same TypeDescriptor twice with different coders; generic method type variables resolving to conflicting context coders during getDefaultCoders for a class hierarchy.","solutions":["Remove duplicate/conflicting registerCoderForType calls so only one coder exists per type.","Register a single explicit coder for the type and retry.","Narrow the requested TypeDescriptor to a concrete type with an unambiguous coder."],"exampleFix":"// before\nregistry.registerCoderForType(TypeDescriptor.of(MyT.class), coderA);\nregistry.registerCoderForType(TypeDescriptor.of(MyT.class), coderB); // conflict\n// after\nregistry.registerCoderForType(TypeDescriptor.of(MyT.class), coderA); // single binding","handlingStrategy":"try-catch","validationCode":"if (registry.getCoderTypeRegistrations().stream()\n    .filter(r -> r.getType().equals(type)).count() > 1) {\n  // conflicting bindings present\n}","typeGuard":null,"tryCatchPattern":"try {\n  coder = registry.getCoder(td);\n} catch (CannotProvideCoderException e) {\n  // ReasonCode.OVER_SPECIFIED: dedupe registrations or pass explicit coder\n}","preventionTips":["Register each type at most once per registry.","Guard shared registry setup code against double registration.","Pass an explicit coder when a type variable has ambiguous bindings."],"tags":["java","apache-beam","coders","ambiguous-binding"],"backgroundTag":"conflicting-config-options","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"}