{"record":{"id":"f9c1420df2fb84ff","repo":"xai-org/x-algorithm","slug":"unknown-struct-value","errorCode":null,"errorMessage":"unknown struct value","messagePattern":"unknown struct value","errorType":"exception","errorClass":"TException","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/types/ThriftStructType.java","lineNumber":713,"sourceCode":"    public void readMessageEnd() throws TException {\n      throw new TException(new UnsupportedOperationException());\n    }\n\n    @Override\n    public TStruct readStructBegin() throws TException {\n      if (!scopes.empty()) {\n        Scope scope = scopes.peek();\n        ThriftStructMetaData structMetadata = (ThriftStructMetaData) scope.getMetaData();\n        ThriftStructType thriftType = ofThriftStruct(structMetadata.structClass);\n        Object value = readValue();\n        if (value instanceof Map) {\n          Map<Object, Object> mapValue = (Map<Object, Object>) value;\n          scopes.push(new MapStructScope(thriftType.metadataMap, mapValue));\n        } else if (value instanceof ThriftStruct) {\n          ThriftStruct structValue = (ThriftStruct) value;\n          scopes.push(new ThriftStructScope(thriftType, structValue));\n        } else {\n          throw new TException(\"unknown struct value\");\n        }\n      } else {\n        scopes.push(new MapStructScope(metadataMap, data));\n      }\n\n      return null;\n    }\n\n    @Override\n    public void readStructEnd() {\n      scopes.pop();\n    }\n\n    @Override\n    public TField readFieldBegin() {\n      StructScope scope = (StructScope) scopes.peek();\n      return scope.readField();\n    }","sourceCodeStart":695,"sourceCodeEnd":731,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/types/ThriftStructType.java#L695-L731","documentation":"TBotMakerMapProtocol.readStructBegin dispatches on the runtime value: Maps push a MapStructScope and ThriftStruct values push a ThriftStructScope. Any other value type throws TException 'unknown struct value'.","triggerScenarios":"Writing a struct-typed value whose runtime object is neither a Map nor a ThriftStruct — e.g. an apache-thrift TBase object, a scala case class, or a JSON primitive placed where a nested struct is expected.","commonSituations":"Feeding botmaker a hand-built value tree (e.g. parsed JSON or test fixtures) where nested struct fields contain non-struct objects; mixing apache-thrift TBase values with scrooge-based botmaker serialization.","solutions":["Ensure nested struct values are Maps or scrooge ThriftStruct instances before writing","Convert TBase objects to Maps or the corresponding ThriftStruct type","Validate the value tree shape against the expected thrift schema before serialization"],"exampleFix":"// before\nmap.put(\"nested\", tBaseObj); // TBase not ThriftStruct\n// after\nmap.put(\"nested\", structTupleOrMapValue); // Map<String,Object> or ThriftStruct","handlingStrategy":"type-guard","validationCode":"if (!(v instanceof Map) && !(v instanceof ThriftStruct)) {\n  throw new IllegalArgumentException(\"nested struct value must be Map or ThriftStruct\");\n}","typeGuard":"boolean isStructValue(Object v) { return v instanceof Map || v instanceof ThriftStruct; }","tryCatchPattern":"catch TException 'unknown struct value' and pinpoint the offending path in the value tree","preventionTips":["Build value trees from thrift structs directly, not ad-hoc objects","Validate value trees against schema in tests"],"tags":["thrift","serialization","type-mismatch"],"backgroundTag":"invalid-serialization-input","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}