Skip to content

Commit 3ad9319

Browse files
committed
fix: bind isBatch on the legacy translate endpoint under Jackson 3
The public legacy endpoint POST /v2/public/translator/translate deserializes into LegacyTolgeeTranslateRequest, whose `isBatch: Boolean` field silently stopped binding after the Spring Boot 4 upgrade moved the JSON stack from Jackson 2 to Jackson 3 (tools.jackson). Requests now fail with request_parse_error (HTTP 400): Missing required creator property 'isBatch' (index 6) Cause: Kotlin compiles a `val isBatch: Boolean` property to the JVM getter `isBatch()` (the `is`-prefixed form, not `getIsBatch()`). Jackson derives a property's external JSON name from its getter and, for an `is`-getter returning boolean, strips the prefix: `isBatch()` -> external name `batch`. Jackson 2 + jackson-module-kotlin kept the external name aligned to the Kotlin property name (`isBatch`), so incoming `"isBatch"` bound. Under Jackson 3 the boolean `is`-getter naming wins, so the field binds to the JSON key `batch` instead; the incoming `"isBatch"` no longer matches, and because the parameter is non-null with no default it is reported as a missing required creator property. The implicit name in the error is still `isBatch` (the constructor parameter name) even though the key Jackson was actually looking for is `batch`. Fix: - @JsonProperty("isBatch") pins the external name back to `isBatch` so real clients (and the SDK/CLI) that send `"isBatch"` bind correctly again, including `isBatch = true`. - `= false` default makes the field optional so requests that omit it do not hit "missing required creator property" regardless of the resolved key name, matching the pre-upgrade behavior where a missing boolean defaulted to false. Surfaced by the billing EeTolgeeTranslatorControllerTest suite, which exercises this endpoint.
1 parent ac42cfc commit 3ad9319

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

ee/backend/app/src/main/kotlin/io/tolgee/ee/data/LegacyTolgeeTranslateRequest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.tolgee.ee.data
22

3+
import com.fasterxml.jackson.annotation.JsonProperty
34
import io.tolgee.model.mtServiceConfig.Formality
45

56
data class LegacyTolgeeTranslateRequest(
@@ -9,7 +10,8 @@ data class LegacyTolgeeTranslateRequest(
910
val targetTag: String,
1011
val metadata: Metadata?,
1112
val formality: Formality?,
12-
val isBatch: Boolean,
13+
@JsonProperty("isBatch")
14+
val isBatch: Boolean = false,
1315
val pluralForms: Map<String, String>? = null,
1416
val pluralFormExamples: Map<String, String>? = null,
1517
) {

0 commit comments

Comments
 (0)