# Schema registry is not accepting a type by reference

**URL:** https://forum.confluent.io/t/schema-registry-is-not-accepting-a-type-by-reference/1526
**Category:** Schema Registry
**Created:** [17 April 2021 16:56 UTC](https://forum.confluent.io/t/schema-registry-is-not-accepting-a-type-by-reference/1526 "2021-04-17T16:56:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![wcn00](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/wcn00/32/709_2.png) [@wcn00](https://forum.confluent.io/u/wcn00)
#### Post date: [17 April 2021 16:56 UTC](https://forum.confluent.io/t/schema-registry-is-not-accepting-a-type-by-reference/1526/1 "2021-04-17T16:56:25Z")

</div>

I have the following schemas:

```json
{
    "namespace": "org.wcn",
    "type": "record",
    "name": "Detail",
    "fields": [
        {
            "name": "quantity",
            "type": "int"
        },
        {
            "name": "total",
            "type": "float"
        }
    ]
}

```

and:

```json
{
    "namespace": "org.wcn",
    "type": "record",
    "doc": "This Schema describes about Order",
    "name": "Order",
    "fields": [
        {
            "name": "order_id",
            "type": "long"
        },
        {
            "name": "customer_id",
            "type": "long"
        },
        {
            "name": "total",
            "type": "float"
        },
        {
            "name": "detail",
            "type": "org.wcn.Detail"
        }
    ]
}

```

These schemas compile and work in code locally, however:

I can upload the first one to schema registry no problem. The second one gets the error:

```auto
ERROR Could not parse Avro schema (io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider)
org.apache.avro.SchemaParseException: "org.wcn.Detail" is not a defined name. The type of the "detail" field must be a defined name or a {"type": ...} expression.

```

This is thrown by the schema registry.

If I reconfigure the schema to be “all in one”:

```json
{
    "namespace": "org.wcn",
    "type": "record",
    "doc": "This Schema describes about Order",
    "name": "OrderComplete",
    "fields": [
        {
            "name": "order_id",
            "type": "long"
        },
        {
            "name": "customer_id",
            "type": "long"
        },
        {
            "name": "total",
            "type": "float"
        },
        {
            "name": "detail",
            "type": {
                "namespace": "org.wcn",
                "type": "record",
                "name": "Detail",
                "fields": [
                    {
                        "name": "quantity",
                        "type": "int"
                    },
                    {
                        "name": "total",
                        "type": "float"
                    }
                ]
            }
        }
    ]
}

```

It will upload with no problems.

However this doesn’t sound like the way schema registry is intended to be used. I thought it would dereference schemas as needed so long as they were previously uploaded.  
Your thoughts will be appreciated.  
wcn

---

<div class="post-metadata">

### Author: ![rick](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rick/32/49_2.png) [@rick](https://forum.confluent.io/u/rick)
#### Post date: [17 April 2021 21:13 UTC](https://forum.confluent.io/t/schema-registry-is-not-accepting-a-type-by-reference/1526/2 "2021-04-17T21:13:31Z")

</div>

@wcn00 can you verify the Confluent Platform version you’re using?

---

<div class="post-metadata">

### Author: ![wcn00](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/wcn00/32/709_2.png) [@wcn00](https://forum.confluent.io/u/wcn00)
#### Post date: [18 April 2021 02:34 UTC](https://forum.confluent.io/t/schema-registry-is-not-accepting-a-type-by-reference/1526/3 "2021-04-18T02:34:32Z")

</div>

I run it with this image:  
confluentinc/cp-schema-registry:6.0.2

Thanks for getting back so fast.  
wcn

---

<div class="post-metadata">

### Author: ![wcn00](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/wcn00/32/709_2.png) [@wcn00](https://forum.confluent.io/u/wcn00)
#### Post date: [18 April 2021 14:24 UTC](https://forum.confluent.io/t/schema-registry-is-not-accepting-a-type-by-reference/1526/4 "2021-04-18T14:24:00Z")

</div>

This is interesting. The info statement when uploading the “detail” type that cannot subsequently be dereferenced is:

INFO Registering new schema: subject org.wcn.Detail, version null, id null, type null (io.confluent.kafka.schemaregistry.rest.resources.SubjectVersionsResource)

The subject looks sensible, but the type is null. When I look into that I find doc relating to the “references” field when posting a schema. For example:

“references”: [  
{  
“name”: “com.acme.Referenced”,  
“subject”: “childSubject”,  
“version”: 1  
}

I’ll investigate from that point of view and update here.  
Note , that in my schema uploads I am not specifying references.

---

<div class="post-metadata">

### Author: ![wcn00](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/wcn00/32/709_2.png) [@wcn00](https://forum.confluent.io/u/wcn00)
#### Post date: [18 April 2021 15:52 UTC](https://forum.confluent.io/t/schema-registry-is-not-accepting-a-type-by-reference/1526/5 "2021-04-18T15:52:32Z")

</div>

Yup, thats it. If you upload a schema which references other schema “types” then they must be explicitly declared in a references list.

ttfn

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)
#### Post date: [25 April 2021 15:53 UTC](https://forum.confluent.io/t/schema-registry-is-not-accepting-a-type-by-reference/1526/6 "2021-04-25T15:53:13Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
