{"record":{"id":"6657da959e22c3d4","repo":"risingwavelabs/risingwave","slug":"failed-to-convert-json-schema-to-avro-schema","errorCode":null,"errorMessage":"failed to convert JSON schema to Avro schema: {}","messagePattern":"failed to convert JSON schema to Avro schema: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/codec/src/decoder/json/mod.rs","lineNumber":210,"sourceCode":"\nimpl crate::JsonSchema {\n    /// ## Notes on type conversion\n    /// Map will be used when an object doesn't have `properties` but has `additionalProperties`.\n    /// When an object has `properties` and `additionalProperties`, the latter will be ignored.\n    /// <https://github.com/mozilla/jsonschema-transpiler/blob/fb715c7147ebd52427e0aea09b2bba2d539850b1/src/jsonschema.rs#L228-L280>\n    ///\n    /// TODO: examine other stuff like `oneOf`, `patternProperties`, etc.\n    pub async fn json_schema_to_columns(\n        &mut self,\n        retrieval_url: Url,\n    ) -> anyhow::Result<Vec<Field>> {\n        JsonRef::new()\n            .deref_value(&mut self.0, &retrieval_url)\n            .await?;\n        let avro_schema =\n            rw_catch_unwind(|| jst::convert_avro(&self.0, jst::Context::default()).to_string())\n                .map_err(|payload| {\n                    anyhow!(\n                        \"failed to convert JSON schema to Avro schema: {}\",\n                        panic_message::panic_message(&payload)\n                    )\n                })?;\n        let schema =\n            apache_avro::Schema::parse_str(&avro_schema).context(\"failed to parse avro schema\")?;\n        avro_schema_to_fields(&schema, Some(MapHandling::Jsonb))\n    }\n}\n","sourceCodeStart":192,"sourceCodeEnd":220,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/codec/src/decoder/json/mod.rs#L192-L220","documentation":"Raised in JsonSchema::json_schema_to_columns (src/connector/codec/src/decoder/json/mod.rs:208-214). After $refs are resolved, the JSON schema is converted to Avro via the `jst` (jsonschema-transpiler) crate inside rw_catch_unwind; if that conversion panics, the panic message is wrapped into `failed to convert JSON schema to Avro schema: {msg}`. This indicates the JSON schema uses constructs the transpiler cannot map to Avro (uncommon keywords, unsupported combinators, or malformed schema shapes).","triggerScenarios":"Calling json_schema_to_columns on a schema whose dereferenced form triggers a panic in `jst::convert_avro` — e.g. JSON Schema keywords with no Avro equivalent, deeply unusual `type` shapes, or null/non-object roots the transpiler does not handle.","commonSituations":"Schemas authored for JSON Schema validation (draft-07 with `oneOf`/`patternProperties`/conditional keywords) being reused as RisingWave protobuf/JSON encoded sources; schemas produced by generators emitting non-standard extensions; empty or `true`/`false` boolean schemas.","solutions":["Simplify the JSON schema to plain object/properties types with scalar leaf types the transpiler supports","Move complex constructs (`oneOf`, `anyOf`, `patternProperties`) into explicitly typed `properties`","Read the panic message in the error to identify the unsupported construct and rewrite it","Pre-convert the schema to Avro yourself and use AVRO encoding instead of JSON schema conversion"],"exampleFix":"// before\n{\"oneOf\": [{\"type\": \"string\"}, {\"type\": \"object\", \"properties\": {\"a\": {\"type\": \"integer\"}}}]}\n// after\n{\"type\": \"object\", \"properties\": {\"a\": {\"type\": \"integer\"}}}","handlingStrategy":"try-catch","validationCode":"// Pre-validate the schema converts cleanly with jsonschema-transpiler before use:\n// cargo run -- schema.json  (or convert with jst in a build step)\nfn is_plain_object_schema(v: &serde_json::Value) -> bool {\n    v.get(\"type\").and_then(|t| t.as_str()) == Some(\"object\")\n        && v.get(\"properties\").map(|p| p.is_object()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match json_schema_to_columns(schema, url).await {\n    Ok(cols) => cols,\n    Err(e) if e.to_string().contains(\"failed to convert JSON schema to Avro schema\") => {\n        // fall back: simplify schema or switch encoding to AVRO\n        Vec::new()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep JSON schemas to plain object/properties/scalar shapes","Avoid oneOf/anyOf/patternProperties in ingestion schemas","Pre-convert to Avro in CI to catch conversion panics before deployment"],"tags":["schema","avro","conversion","panic"],"backgroundTag":"schema-validation-failed","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}