zhangshenghang opened a new pull request, #11526:
URL: https://github.com/apache/seatunnel/pull/11526
## Purpose of the change
Fixes #9677.
A Milvus source → Milvus sink sync fails whenever a JSON field holds a
non-object value:
```
com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject
but was com.google.gson.JsonPrimitive
at
...MilvusSinkConverter.convertBySeaTunnelType(MilvusSinkConverter.java:73)
```
## Root cause
`MilvusSinkConverter.convertBySeaTunnelType` parsed STRING values of JSON
fields with `gson.fromJson(value.toString(), JsonObject.class)`. A Milvus
`JSON` field may legally hold **any JSON root** — object, array, or primitive
(string/number/boolean). Forcing `JsonObject` makes every non-object value blow
up the whole job, even though the source read works fine.
## Changes
- **`MilvusSinkConverter`** — parse to a generic `JsonElement` via
`JsonParser.parseString(...)`:
- Object roots still parse to `JsonObject`, so existing behavior is
preserved (the downstream `gson.toJsonTree(object)` step in `buildMilvusData`
just returns the element as-is).
- Primitive and array roots now convert correctly instead of throwing.
- **`MilvusSinkConverterTest`** — added cases for `convertBySeaTunnelType`:
- object root → `JsonObject` with fields intact
- primitive roots (`"abc"`, `123`, `true`) → `JsonPrimitive`
- array root (`[1,2,3]`) → `JsonArray`
- non-JSON string passes through unchanged
## Verification
- `./mvnw -pl seatunnel-connectors-v2/connector-milvus test` — full module
suite passes (36 tests).
--
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]