-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.lang.ArrayIndexOutOfBoundsException in JsonStringBuilder 1.2.0 #1460
Comments
I'm seeing this too. Reverted to v1.1.0 to work around it. Additionally seeing the occasional incorrectly encoded JSON string with a double quote missing. |
Also reproduces for me on serialization of a long stacktrace. Seems rather critical to me stopping from updating actually |
This is critical level bug and we have seen this in the wild with 1.2.0. |
I'm getting the same issue. To reproduce import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.json.Json
val query = """query AllAvailableProductsAndUpdatesQuery(${"$"}cursor: String) {
availableProducts: products(first: 250) {
edges {
node {
id
}
}
}
upsertedProducts: products(first: 250, sortKey: UPDATED_AT, after: ${"$"}cursor) {
edges {
cursor
node {
...product
}
}
}
}
fragment product on Product {
id
title
handle
descriptionHtml
productType
tags
createdAt
updatedAt
variants(first: 10) {
edges {
node {
...productVariant
}
}
}
images(first: 10) {
edges {
node {
...image
}
}
}
nutritionCalories: metafield(namespace: "nutrition", key: "calories") {
...metafield
}
nutritionProtein: metafield(namespace: "nutrition", key: "protein") {
...metafield
}
nutritionCarbohydrates: metafield(namespace: "nutrition", key: "carbs") {
...metafield
}
nutritionFat: metafield(namespace: "nutrition", key: "fat") {
...metafield
}
}
fragment productVariant on ProductVariant {
id
title
priceV2 {
...money
}
compareAtPriceV2 {
...money
}
availableForSale
}
fragment image on Image {
originalSrc
}
fragment metafield on Metafield {
value
}
fragment money on MoneyV2 {
amount
}"""
Json.encodeToString(String.serializer(), query) An interesting discovery is that if I try and encode a longer string before encoding
I binary searched to get I'm guessing there's some counting error when trying to encode escaped characters. |
Duplicate with #1441 |
It appears I am blind, I remember searching the exception tho, sorry for the duplicate |
oh I didnt mean to close it |
Reproducer:
|
I'll close this as a duplicate. We'll fix this bug and release 1.2.1 soon |
Describe the bug
java.lang.ArrayIndexOutOfBoundsException when using Json.encodeToString() with some input, idk what exactly is causing it
Stacktrace:
To Reproduce
Expected behavior
Returns the String that was passed to the encodeToString() fucntion
Environment
The text was updated successfully, but these errors were encountered: