{"record":{"id":"43ed75db8fb2876f","repo":"apache/pulsar","slug":"schema-typed-schema-getclass-getname-simp","errorCode":null,"errorMessage":"Schema typed [<schema.getClass().getName()>], simple-type:[<schema.getType()>] is not supported. schema-content: <schema>","messagePattern":"Schema typed \\[<schema\\.getClass\\(\\)\\.getName\\(\\)>\\], simple-type:\\[<schema\\.getType\\(\\)>\\] is not supported\\. schema-content: <schema>","errorType":"exception","errorClass":"AvroRuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericSchemaImpl.java","lineNumber":51,"sourceCode":" * we suggest migrate GenericSchemaImpl.of() to  <GenericSchema Implementor>.of() method\n * (e.g. GenericJsonSchema 、GenericAvroSchema )\n */\npublic abstract class GenericSchemaImpl extends AvroBaseStructSchema<GenericRecord>\n        implements GenericSchema<GenericRecord> {\n\n    protected final List<Field> fields;\n\n    protected GenericSchemaImpl(SchemaInfo schemaInfo) {\n        super(schemaInfo);\n\n        try {\n            this.fields = schema.getFields()\n                    .stream()\n                    .map(f -> new Field(f.name(), f.pos()))\n                    .collect(Collectors.toList());\n        } catch (AvroRuntimeException avroRuntimeException) {\n            // Rewrite error log.\n            throw new AvroRuntimeException(\"Schema typed [\" + schema.getClass().getName() + \"], simple-type:[\"\n                    + schema.getType() + \"] is not supported. schema-content: \" + schema);\n        }\n    }\n\n    @Override\n    public List<Field> getFields() {\n        return fields;\n    }\n\n    /**\n     * Create a generic schema out of a <tt>SchemaInfo</tt>.\n     *  warning : we suggest migrate GenericSchemaImpl.of() to  <GenericSchema Implementor>.of() method\n     *  (e.g. GenericJsonSchema 、GenericAvroSchema )\n     * @param schemaInfo schema info\n     * @return a generic schema instance\n     */\n    public static GenericSchemaImpl of(SchemaInfo schemaInfo) {\n        return of(schemaInfo, true);","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericSchemaImpl.java#L33-L69","documentation":"GenericSchemaImpl's constructor extracts field names/positions from the underlying Avro schema via schema.getFields(). If the schema object does not support Avro field access, Avro throws AvroRuntimeException, which is rethrown with a rewritten message naming the schema class, simple type, and content. It means the supplied schema cannot be used as an Avro generic record schema.","triggerScenarios":"Constructing GenericSchemaImpl (directly or via a subclass) with a Schema object whose getFields() raises AvroRuntimeException — e.g. a primitive-typed schema, malformed Avro schema, or a non-record schema passed where a record schema is required.","commonSituations":"Passing a primitive schema (STRING/INT) instead of a record schema; corrupt or hand-written SchemaInfo JSON that Avro cannot parse; programmatically constructed Avro schemas of unexpected type (ARRAY, MAP) fed to the generic record schema.","solutions":["Verify the schema is an Avro RECORD type before wrapping it in GenericSchemaImpl","Check the schema content printed in the message for malformed JSON/Avro syntax","Use SchemaInfo with a valid record-type Avro definition","Catch AvroRuntimeException at construction and surface a clear validation error to the caller"],"exampleFix":"// before\nGenericSchemaImpl.of(badSchemaInfo); // AvroRuntimeException\n// after\nif (SchemaType.AVRO.equals(badSchemaInfo.getType()) && isValidAvroRecordSchema(badSchemaInfo.getSchema())) {\n    GenericSchemaImpl.of(badSchemaInfo);\n} else {\n    throw new IllegalArgumentException(\"SchemaInfo must contain a valid Avro RECORD schema\");\n}","handlingStrategy":"validation","validationCode":"Schema avroSchema = new Schema.Parser().setValidate(true).parse(new String(schemaInfo.getSchema(), StandardCharsets.UTF_8));\nif (avroSchema.getType() != Schema.Type.RECORD) {\n    throw new IllegalArgumentException(\"GenericSchemaImpl requires an Avro RECORD schema, got: \" + avroSchema.getType());\n}","typeGuard":"boolean isAvroRecordSchema(SchemaInfo info) {\n    try {\n        return new Schema.Parser().parse(new String(info.getSchema(), StandardCharsets.UTF_8)).getType() == Schema.Type.RECORD;\n    } catch (RuntimeException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    GenericSchemaImpl.of(schemaInfo);\n} catch (AvroRuntimeException e) {\n    log.error(\"Schema not usable as Avro generic record schema: {}\", e.getMessage());\n    throw new IllegalArgumentException(\"Provide a valid Avro RECORD schema\", e);\n}","preventionTips":["Validate Avro schema JSON with Schema.Parser before constructing generic schemas","Only pass RECORD-type Avro schemas to generic record schema APIs","Never hand-edit SchemaInfo schema bytes without validating them","Log schema content on failure — the message already includes it"],"tags":["pulsar","avro","schema","generic-schema"],"backgroundTag":"unsupported-schema-type","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}