{"record":{"id":"255eea275d1393e7","repo":"xai-org/x-algorithm","slug":"expect-a-fieldaccessibletype-but-s-received","errorCode":null,"errorMessage":"expect a FieldAccessibleType, but %s received","messagePattern":"expect a FieldAccessibleType, but (.+?) received","errorType":"validation","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/function/thrift/FieldAccessor.java","lineNumber":47,"sourceCode":"  protected CacheLevel getCacheLevel() {\n    return CacheLevel.Global;\n  }\n\n  private static ASTNode.Signature getSignature(ASTNode node, Type valueType) {\n    return new ASTNode.Signature(ImmutableList.of(node.getReturnType()), valueType);\n  }\n\n  @SuppressWarnings(\"unchecked\")\n  public static ASTNode mkFieldAccessor(\n      String exprText,\n      ASTNode node,\n      ImmutableList<String> fields\n  ) throws SemanticCheckFailure {\n\n\n\n    if (!(node.getReturnType() instanceof FieldAccessibleType)) {\n      throw new SemanticCheckFailure(\n          String.format(\"expect a FieldAccessibleType, but %s received\",\n              node.getReturnType().toString())\n      );\n    }\n\n    List<Tuple3<FieldAccessibleType, Type, Function<Object, Object>>> fieldInfosBuilder =\n        Lists.newArrayListWithCapacity(fields.size());\n    FieldAccessibleType objType = (FieldAccessibleType) node.getReturnType();\n    for (String field : fields.subList(0, fields.size() - 1)) {\n      Tuple3<FieldAccessibleType, Type, Function<Object, Object>> fieldInfo =\n          getFieldInfo(objType, field);\n      fieldInfosBuilder.add(fieldInfo);\n      if (!(fieldInfo.getSecond() instanceof FieldAccessibleType)) {\n        throw new SemanticCheckFailure(\n            String.format(\"expect a FieldAccessibleType, but %s received\",\n                fieldInfo.getSecond().toString())\n        );\n      }","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/function/thrift/FieldAccessor.java#L29-L65","documentation":"FieldAccessor.mkFieldAccessor throws SemanticCheckFailure when the root node's return type is not a FieldAccessibleType (i.e. not a thrift struct/union/map-like type with accessible fields). Field access paths like a.b.c require the base expression to be field-accessible.","triggerScenarios":"Applying toFieldAccessor to a node whose getReturnType() is a primitive, string, or collection, e.g. building a field accessor over a Constant or over a numeric expression.","commonSituations":"Typos in field paths, accessing fields on scalar intermediates, schema changes that made the base type non-struct, or wiring the wrong source node into the accessor.","solutions":["Check the base expression's return type and fix it to produce a thrift struct/FieldAccessibleType","If the type changed after a schema update, regenerate/refresh the type definitions","Verify you passed the intended node (not a child/constant) to toFieldAccessor"],"exampleFix":"// before\nFieldAccessor.mkFieldAccessor(constantNode, fields); // returns String -> failure\n// after\nFieldAccessor.mkFieldAccessor(structNode, fields); // returns thrift struct type\n","handlingStrategy":"type-guard","validationCode":"if (!(node.getReturnType() instanceof FieldAccessibleType)) {\n  throw new IllegalArgumentException(\"base expression is not field-accessible: \" + node.getReturnType());\n}","typeGuard":"public static boolean isFieldAccessible(ASTNode n) {\n  return n.getReturnType() instanceof FieldAccessibleType;\n}","tryCatchPattern":"try {\n  return FieldAccessor.mkFieldAccessor(node, fields);\n} catch (SemanticCheckFailure e) {\n  // log base type and field path, fail expression compilation with context\n}","preventionTips":["Check getReturnType() instanceof FieldAccessibleType before building accessors","Keep a registry of base expressions and their expected thrift struct types","Re-run semantic checks after thrift schema regeneration"],"tags":["thrift","field-access","semantic-check","type-mismatch"],"backgroundTag":"field-access-on-non-struct","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}