{"record":{"id":"eeb13df26e8983a0","repo":"xai-org/x-algorithm","slug":"cannot-create-structtuple-type-without-a-fieldname","errorCode":null,"errorMessage":"Cannot create StructTuple Type without a fieldName list.","messagePattern":"Cannot create StructTuple Type without a fieldName list\\.","errorType":"exception","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/types/Type.java","lineNumber":332,"sourceCode":"  public static ThriftStructType thriftStructOf(\n      Class<? extends ThriftStruct> typeBase) {\n    return ThriftStructType.ofThriftStruct(typeBase);\n  }\n\n  static Type of(Class<?> typeBase, ImmutableList<Type> typeParams)\n      throws SemanticCheckFailure {\n    if (List.class.isAssignableFrom(typeBase) && typeParams.size() == 1) {\n      return listOf(typeParams.get(0));\n    } else if (Set.class.isAssignableFrom(typeBase) && typeParams.size() == 1) {\n      return setOf(typeParams.get(0));\n    } else if (Collection.class.isAssignableFrom(typeBase) && typeParams.size() == 1) {\n      return collectionOf(typeParams.get(0));\n    } else if (Map.class.isAssignableFrom(typeBase) && typeParams.size() == 2) {\n      return mapOf(typeParams.get(0), typeParams.get(1));\n    } else if (Pair.class.isAssignableFrom(typeBase) && typeParams.size() == 2) {\n      return pairOf(typeParams.get(0), typeParams.get(1));\n    } else if (StructTuple.class.isAssignableFrom(typeBase) && typeParams.size() > 0) {\n      throw new SemanticCheckFailure(\n          \"Cannot create StructTuple Type without a fieldName list.\");\n    } else if (Tuple.class.isAssignableFrom(typeBase) && typeParams.size() > 0) {\n      return tupleOf(typeParams.toArray(new Type[]{}));\n    } else if (TBase.class.isAssignableFrom(typeBase) && typeParams.size() == 0) {\n      return thriftOf((Class<? extends TBase>) typeBase);\n    } else if (TEnum.class.isAssignableFrom(typeBase) && typeParams.size() == 0) {\n      return thriftEnumOf((Class<? extends TEnum>) typeBase);\n    } else if (ThriftStruct.class.isAssignableFrom(typeBase) && typeParams.size() == 0) {\n      return thriftStructOf((Class<? extends ThriftStruct>) typeBase);\n    } else if (ByteBuffer.class.isAssignableFrom(typeBase) && typeParams.size() == 0) {\n      return Type.BINARY;\n    } else if (PRIMITIVE_TYPES.containsKey(typeBase) && typeParams.size() == 0) {\n      return PRIMITIVE_TYPES.get(typeBase);\n    } else {\n      return Type.of(typeBase, typeParams, Serializer.OBJECT);\n    }\n  }\n","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/types/Type.java#L314-L350","documentation":"Type.of constructs a Type from a raw class plus type parameters. StructTuple requires an explicit field-name list, so constructing it via Type.of with type params but no names is rejected with SemanticCheckFailure.","triggerScenarios":"Type.of(StructTuple.class, someTypes...) or reflective construction paths (listOf/setOf/collectionOf/pairOf/mapOf falling through) that hit the StructTuple branch — i.e. building a StructTuple Type without the (Class, List<String>, Type...) overload.","commonSituations":"See trigger scenarios.","solutions":["Use the dedicated StructTuple factory (e.g. Type.structTupleOf(class, fieldNames, types...)) that supplies field names","Avoid Type.of for StructTuple; reserve it for Tuple/Map/Pair/thrift types","Pass a field-name list alongside the element types"],"exampleFix":"// before\nType t = Type.of(MyTuple.class, Type.INT, Type.STRING);\n// after\nType t = Type.structTupleOf(MyTuple.class,\n    ImmutableList.of(\"id\", \"name\"), Type.INT, Type.STRING);","handlingStrategy":"validation","validationCode":"if (StructTuple.class.isAssignableFrom(typeBase)) {\n  throw new IllegalArgumentException(\"use structTupleOf with field names\");\n}","typeGuard":null,"tryCatchPattern":"catch SemanticCheckFailure 'Cannot create StructTuple Type' and switch to the field-name-aware factory","preventionTips":["Never call Type.of for StructTuple; use the (class, names, types...) overload","Document tuple vs structTuple construction clearly"],"tags":["type-system","struct-tuple","api-misuse"],"backgroundTag":"invalid-type-construction","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}