Skip to content

Commit b354224

Browse files
akoclaude
andcommitted
fix: import mapping writer must use pre-computed JsonPath from executor
The writer was recomputing JsonPath from ExposedName, but now that root ExposedName is 'Root' (not empty), it produced '(Object)|Root' instead of '(Object)'. The executor already computes correct JsonPaths aligned with the JSON structure — the writer should use them directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e44a2d4 commit b354224

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

sdk/mpr/writer_import_mapping.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ func serializeImportMappingElement(elem *model.ImportMappingElement, parentPath
9999
}
100100

101101
func serializeImportObjectElement(id string, elem *model.ImportMappingElement, parentPath string) bson.M {
102-
// Compute JsonPath: root element (empty ExposedName) stays at parentPath;
103-
// named elements append |key to navigate into the nested JSON object.
104-
// Note: the |(Object) suffix is only used for array item elements (empty ExposedName
105-
// inside an array container), not for regular named nested objects.
106-
var jsonPath string
107-
if elem.ExposedName == "" {
108-
jsonPath = parentPath
109-
} else {
110-
jsonPath = parentPath + "|" + elem.ExposedName
102+
// Use pre-computed JsonPath from the executor when available.
103+
// The executor aligns JsonPath with the JSON structure element paths.
104+
jsonPath := elem.JsonPath
105+
if jsonPath == "" {
106+
if elem.ExposedName == "" {
107+
jsonPath = parentPath
108+
} else {
109+
jsonPath = parentPath + "|" + elem.ExposedName
110+
}
111111
}
112112

113113
children := bson.A{int32(2)}
@@ -148,7 +148,10 @@ func serializeImportObjectElement(id string, elem *model.ImportMappingElement, p
148148

149149
func serializeImportValueElement(id string, elem *model.ImportMappingElement, parentPath string) bson.M {
150150
dataType := serializeImportValueDataType(elem.DataType)
151-
jsonPath := parentPath + "|" + elem.ExposedName
151+
jsonPath := elem.JsonPath
152+
if jsonPath == "" {
153+
jsonPath = parentPath + "|" + elem.ExposedName
154+
}
152155

153156
return bson.M{
154157
"$ID": idToBsonBinary(id),

0 commit comments

Comments
 (0)