github-advanced-security[bot] commented on code in PR #3727:
URL: https://github.com/apache/avro/pull/3727#discussion_r3051823843


##########
lang/csharp/src/apache/test/Schema/SchemaTests.cs:
##########
@@ -567,12 +568,76 @@
             testToString(sc);
         }
 
+        // Make sure unknown type is carried thru to LogicalTypeName
         [TestCase("{\"type\": \"int\", \"logicalType\": \"unknown\"}", 
"unknown")]
         public void TestUnknownLogical(string s, string unknownType)
         {
-            var err = Assert.Throws<AvroTypeException>(() => Schema.Parse(s));
+            var schema = Schema.Parse(s);
+            Assert.IsNotNull(schema);   // make sure Variable is not null
+            Assert.IsInstanceOf(typeof(LogicalSchema), schema);
 
-            Assert.AreEqual("Logical type '" + unknownType + "' is not 
supported.", err.Message);
+            var logicalSchema = schema as LogicalSchema;
+            Assert.IsNotNull(logicalSchema);   // make sure Variable is not 
null
+            Assert.IsInstanceOf(typeof(UnknownLogicalType), 
logicalSchema.LogicalType);
+
+            Assert.AreEqual(logicalSchema.LogicalTypeName, unknownType);
+        }
+
+        /*
+            {
+              "fields": [
+                {
+                  "default": 0,
+                  "name": "firstField",
+                  "type": "int"
+                },
+                {
+                  "default": null,
+                  "name": "secondField",
+                  "type": [
+                    "null",
+                    {
+                      "logicalType": "varchar",
+                      "maxLength": 65,
+                      "type": "string"
+                    }
+                  ]
+                }
+              ],
+              "name": "sample_schema",
+              "type": "record"
+            }
+         */
+
+        // Before Change will throw Avro.AvroTypeException: 'Logical type 
'varchar' is not supported.'
+        // Per AVRO Spec (v1.8.0 - v1.11.1) ... Logical Types Section
+        //  Language implementations must ignore unknown logical types when 
reading, and should use the underlying Avro type.
+        [TestCase("{\"fields\": [{\"default\": 0,\"name\": 
\"firstField\",\"type\": \"int\"},{\"default\": null,\"name\": 
\"secondField\",\"type\": [\"null\",{\"logicalType\": 
\"varchar\",\"maxLength\": 65,\"type\": \"string\"}]}],\"name\": 
\"sample_schema\",\"type\": \"record\"}")]
+        public void TestUnknownLogicalType(string schemaText)
+        {
+            var schema = Avro.Schema.Parse(schemaText);
+            Assert.IsNotNull(schema);

Review Comment:
   ## CodeQL / Dereferenced variable may be null
   
   Variable [logicalSchema](1) may be null at this access because of [this](2) 
assignment.
   
   [Show more 
details](https://github.com/apache/avro/security/code-scanning/3193)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to