{"record":{"id":"9e38affd48e79dc0","repo":"apache/beam","slug":"unknown-type-attributevaluecoder","errorCode":null,"errorMessage":"Unknown Type","messagePattern":"Unknown Type","errorType":"exception","errorClass":"CoderException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/dynamodb/AttributeValueCoder.java","lineNumber":102,"sourceCode":"      StringUtf8Coder.of().encode(AttributeValueType.ss.toString(), outStream);\n      LIST_STRING_CODER.encode(value.ss(), outStream);\n    } else if (value.ns() != null && value.ns().size() > 0) {\n      StringUtf8Coder.of().encode(AttributeValueType.ns.toString(), outStream);\n      LIST_STRING_CODER.encode(value.ns(), outStream);\n    } else if (value.bs() != null && value.bs().size() > 0) {\n      StringUtf8Coder.of().encode(AttributeValueType.bs.toString(), outStream);\n      LIST_BYTE_CODER.encode(convertToListByteArray(value.bs()), outStream);\n    } else if (value.l() != null && value.l().size() > 0) {\n      StringUtf8Coder.of().encode(AttributeValueType.l.toString(), outStream);\n      LIST_ATTRIBUTE_CODER.encode(value.l(), outStream);\n    } else if (value.m() != null && value.m().size() > 0) {\n      StringUtf8Coder.of().encode(AttributeValueType.m.toString(), outStream);\n      MAP_ATTRIBUTE_CODER.encode(value.m(), outStream);\n    } else if (value.nul() != null) {\n      StringUtf8Coder.of().encode(AttributeValueType.nul.toString(), outStream);\n      BooleanCoder.of().encode(value.nul(), outStream);\n    } else {\n      throw new CoderException(\"Unknown Type\");\n    }\n  }\n\n  @Override\n  public AttributeValue decode(InputStream inStream) throws IOException {\n    AttributeValue.Builder attrBuilder = AttributeValue.builder();\n\n    String type = StringUtf8Coder.of().decode(inStream);\n    AttributeValueType attrType = AttributeValueType.valueOf(type);\n\n    switch (attrType) {\n      case s:\n        attrBuilder.s(StringUtf8Coder.of().decode(inStream));\n        break;\n      case n:\n        attrBuilder.n(StringUtf8Coder.of().decode(inStream));\n        break;\n      case bool:","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/dynamodb/AttributeValueCoder.java#L84-L120","documentation":"AttributeValueCoder.encode throws CoderException(\"Unknown Type\") when the DynamoDB AttributeValue being encoded has none of its supported typed fields set (s, n, b, ss, ns, bs, m, l, nul, etc.). It is a defensive terminal branch indicating the AttributeValue is empty or uses a field the coder doesn't handle.","triggerScenarios":"Encoding an AttributeValue built without setting any typed value (e.g. AttributeValue.builder().build()), or an AttributeValue from a newer AWS SDK version carrying a field this coder doesn't recognize.","commonSituations":"Constructing items programmatically with an accidentally empty AttributeValue; DynamoDB returning a value shape the Beam coder version predates; null/empty maps written to DynamoDB then read back through Beam writes.","solutions":["Check which AttributeValue triggered it and ensure exactly one typed field is set","Fix upstream code that builds empty AttributeValues (e.g. skip null fields)","Upgrade the Beam AWS2 IO / SDK so the coder covers all AttributeValue variants","Validate items before writing: assert at least one of s/n/b/ss/ns/bs/m/l/nul is non-null"],"exampleFix":"// before: empty value slips through\nAttributeValue v = AttributeValue.builder().build();\nitems.put(\"key\", v);\n// after: guard before writing\nif (v.s() == null && v.n() == null && v.b() == null && v.m() == null\n    && v.l() == null && v.ss() == null && v.nul() == null) {\n  throw new IllegalArgumentException(\"AttributeValue has no type set\");\n}","handlingStrategy":"validation","validationCode":"boolean isValid(AttributeValue v) {\n  return v.s() != null || v.n() != null || v.b() != null || v.ss() != null\n      || v.ns() != null || v.bs() != null || v.m() != null || v.l() != null\n      || v.nul() != null;\n}","typeGuard":"boolean hasTypedValue(AttributeValue v) {\n  return v.s() != null || v.n() != null || v.b() != null\n      || v.m() != null || v.l() != null || v.nul() != null;\n}","tryCatchPattern":"try {\n  coder.encode(value, outStream);\n} catch (CoderException e) {\n  logger.error(\"AttributeValue has no supported type set\", e);\n  throw e;\n}","preventionTips":["Always set exactly one typed field on AttributeValue","Skip null values instead of encoding empty AttributeValues","Keep Beam AWS2 IO updated for new AttributeValue variants"],"tags":["java","aws-dynamodb","coder-encoding","serialization"],"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"}