From 89e09dd154a5aeb5ae29dc85ced26f6f568e8325 Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Mon, 6 Jul 2026 16:14:56 -0400 Subject: [PATCH 1/2] Pass forwarding ref when unifying objects into a map UnifyUnionBuilder.makeObject's map branch called getMapType without the pending forwardingRef, while the class/object branches pass it through. When inferMaps rewrites sibling classes that unify into a map (e.g. a map-typed field whose values contain both non-empty and empty maps), the type creator then returned a ref different from its forwarding ref, tripping the "Type creator didn't return its forwarding ref" assert in GraphRewriteBuilder.withForwardingRef and crashing for every target language. Add the minimized JSON from issue #2037 as a priority regression fixture; it crashed before this fix and now converts for all languages. Fixes #2037 Co-Authored-By: Claude Fable 5 --- packages/quicktype-core/src/UnifyClasses.ts | 1 + test/inputs/json/priority/bug2037.json | 1 + 2 files changed, 2 insertions(+) create mode 100644 test/inputs/json/priority/bug2037.json diff --git a/packages/quicktype-core/src/UnifyClasses.ts b/packages/quicktype-core/src/UnifyClasses.ts index 5c1e0094eb..63deb15a62 100644 --- a/packages/quicktype-core/src/UnifyClasses.ts +++ b/packages/quicktype-core/src/UnifyClasses.ts @@ -191,6 +191,7 @@ export class UnifyUnionBuilder extends UnionBuilder< return this.typeBuilder.getMapType( typeAttributes, this._unifyTypes(Array.from(propertyTypes)), + forwardingRef, ); } else { const [properties, additionalProperties, lostTypeAttributes] = diff --git a/test/inputs/json/priority/bug2037.json b/test/inputs/json/priority/bug2037.json new file mode 100644 index 0000000000..3c02da6267 --- /dev/null +++ b/test/inputs/json/priority/bug2037.json @@ -0,0 +1 @@ +{"mission_specs": {"1": {"objectives": {"2": {"rewards": {"3": {}, "5": {}}}}}, "4": {"objectives": {"6": {"rewards": {}}}}}} From 2d120b5cbe723a5229e7ff4a7461e12782e6dffc Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Mon, 6 Jul 2026 16:48:53 -0400 Subject: [PATCH 2/2] Skip empty object map fixture for Kotlin Klaxon --- test/languages.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/languages.ts b/test/languages.ts index a31f78b6f5..14148e136a 100644 --- a/test/languages.ts +++ b/test/languages.ts @@ -1168,6 +1168,8 @@ export const KotlinLanguage: Language = { "nst-test-suite.json", // Klaxon does not support top-level primitives "no-classes.json", + // Klaxon cannot deserialize empty object map values as JsonObject: #2881 + "bug2037.json", // These should be enabled "nbl-stats.json", // TODO Investigate these