[ 
https://issues.apache.org/jira/browse/AVRO-4265?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated AVRO-4265:
---------------------------------
    Labels: pull-request-available  (was: )

> Default values fail on forward references
> -----------------------------------------
>
>                 Key: AVRO-4265
>                 URL: https://issues.apache.org/jira/browse/AVRO-4265
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.12.0, 1.12.1
>            Reporter: Oscar Westra van Holthe - Kind
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> This issue was reported in a [GitHub 
> discussion|https://github.com/apache/avro/pull/3614#discussion_r3325140758] 
> by [ebAtUelzener|https://github.com/ebAtUelzener]:
> You can observe that the Gradle task fails with a cause inside the validation 
> Schema.validateDefault:
> {noformat}
> org.gradle.api.tasks.TaskExecutionException: Execution failed for task 
> ':avroGenerateJavaClasses'
> <gradle stack>
> Caused by: org.apache.avro.AvroTypeException: Invalid default for field 
> myEnum: "NONE" not a 
> {"type":"record","name":"UnresolvedSchema_1","namespace":"org.apache.avro.compiler","doc":"unresolved
>  schema","fields":[],"org.apache.avro.idl.unresolved.name":"some.MyEnum"}
>       at org.apache.avro.Schema.validateDefault(Schema.java:1720)
>       at org.apache.avro.Schema$Field.<init>(Schema.java:579)
>       at org.apache.avro.Schema.parseField(Schema.java:1904)
>       at org.apache.avro.Schema.parseRecord(Schema.java:1872)
>       at org.apache.avro.Schema.parse(Schema.java:1836)
>       at org.apache.avro.Schema$Parser.parse(Schema.java:1539)
>       at org.apache.avro.Schema$Parser.parseInternal(Schema.java:1524)
>       at org.apache.avro.JsonSchemaParser.parse(JsonSchemaParser.java:86)
>       at org.apache.avro.JsonSchemaParser.parse(JsonSchemaParser.java:77)
>       at org.apache.avro.SchemaParser.parse(SchemaParser.java:245)
>       at org.apache.avro.SchemaParser.parse(SchemaParser.java:137)
>       at org.apache.avro.SchemaParser.parse(SchemaParser.java:103)
>       at org.apache.avro.SchemaParser.parse(SchemaParser.java:88)
>       at 
> eu.eventloopsoftware.avro.gradle.plugin.tasks.CompileAvroSchemaTask.compileSchemas(CompileAvroSchemaTask.kt:65)
>       at 
> eu.eventloopsoftware.avro.gradle.plugin.tasks.CompileAvroSchemaTask.compileSchema(CompileAvroSchemaTask.kt:42)
> {noformat}
> This can be reproduced (somewhat, depends on order they are sent to the 
> parser) by having two files, an enum and a record like so:
> Enum schema:
> {code:json}
> {
>   "type": "enum",
>   "name": "MyEnum",
>   "namespace": "some",
>   "symbols": [
>     "SOME"
>     "NONE"
>   ]
> }
> {code}
> Record schema:
> {code:json}
> {
>   "type": "record",
>   "name": "MyRecord",
>   "namespace": "some",
>   "fields": [
>     {
>         "name": "myEnum",
>         "type": "MyEnum",
>         "default": "NONE"
>     }
>   ]
> }
> {code}
> Question is, is this a bug inside the {{avro-compiler}} package rather than 
> an issue here and if so should the plugin accommodate for this bug in the 
> meantime or not?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to