ListRecord.Field array-shaped `message` still fails in the production GsonFactory (follow-up to #1587)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 GsonFactory.registerTypeAdapters 和 GsonListViewGroupingFactory 開始;issue 提議將 GsonListRecordFieldFactory 移至 slack-api-model/src/main/java/com/slack/api/util/json/,並在 production factory 中註冊它。查看現有的測試 adapter 和 ListRecordFieldTest,了解對單一物件和陣列的預期處理方式。production GsonFactory 能成功解析這兩種形式後,工作即告完成。
由索引模型根據 Issue 內容生成。
描述
Issue summary
When the Slack API returns a conversations.replies (or conversations.history) response that contains a Slack Lists item attachment, the SDK throws JsonSyntaxException whenever any ListRecord.Field.message value is a JSON array instead of a single object. The whole API call fails, and no Message data is returned.
This is the bug from #1587. #1590 (released in v1.49.0) closed #1587, but the bug is still in the production code path in v1.52.0.
Affected versions
- v1.46.0 through v1.48.1 (verified in #1587; also seen in production on v1.48.1)
- v1.49.0 through v1.52.0: the production
GsonFactoryhas no adapter forListRecord.Field. @maoppay saw the failure on v1.50.0 (comment in #1587), and the live probe in #1644 shows it too.
Why #1590 was not sufficient
#1590 changed two things:
ListRecord.Field(slack-api-model/src/main). It addedprivate transient List<Message> messagesandgetMessages()/setMessages(). The fieldmessageis still a singleMessage. Gson skipstransientfields and sets fields by reflection, not through setters. So without an adapter, Gson still maps the JSON keymessageto theMessagefield, and an array still fails.GsonListRecordFieldFactory, the adapter that converts the array. #1590 put it inslack-api-model/src/test/java/test_locally/util/list/and registered it only in the testGsonFactory(slack-api-model/src/test/java/test_locally/unit/GsonFactory.java).
ListRecordFieldTest parses with that test GsonFactory, so it passes. Real API calls parse with com.slack.api.util.json.GsonFactory in slack-api-client (MethodsClientImpl calls GsonFactory.createSnakeCase(config)), and that class does not register the adapter. Also, the json-logs/samples/api samples still have message as a single object, so the MockSlackApi tests (for example ConversationsTest) never see the array shape.
Minimal reproduction
import com.google.gson.Gson;
import com.slack.api.methods.response.conversations.ConversationsRepliesResponse;
import com.slack.api.util.json.GsonFactory;
public class Repro {
public static void main(String[] args) {
// Mirrors the shape Slack returns when a Lists item's `message` field
// has multiple values (array form).
String payload =
"{\"ok\":true,\"messages\":[{\"type\":\"message\",\"user\":\"U1\",\"ts\":\"1.0\","
+ "\"text\":\"hi\",\"attachments\":[{\"list_record\":{\"record\":{\"fields\":["
+ "{\"key\":\"name\",\"message\":{\"text\":\"ok\"}},"
+ "{\"key\":\"details\",\"message\":[{\"text\":\"a\"},{\"text\":\"b\"}]}"
+ "]}}}]}]}";
Gson sdkGson = GsonFactory.createSnakeCase();
// Still throws JsonSyntaxException on v1.52.0 at
// $.messages[0].attachments[0].list_record.record.fields[1].message
ConversationsRepliesResponse parsed =
sdkGson.fromJson(payload, ConversationsRepliesResponse.class);
}
}
Expected behavior
The SDK accepts both single-object and array shapes for ListRecord.Field.message in real API responses, as getMessages() from #1590 intends.
Proposed fix
#1654 moves GsonListRecordFieldFactory to slack-api-model/src/main/java/com/slack/api/util/json/ (next to GsonListViewGroupingFactory) and registers it in GsonFactory.registerTypeAdapters.
- 主要語言
- Java
- 星號
- 602
- 分支
- 237
- 平均合併
- 1 天 7 小時
- 30 天內合併 PR
- 13
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
slackapi/java-slack-sdk 的其他 Issue
-
`MethodsClient` throws `NumberFormatException` instead of `SlackApiException` when a 429 response has a non-numeric `Retry-After` header可能已有人在做 @hidingmyname 於 1 天前認領。 未關閉bug project:slack-api-client
難度 3/5 半天 新手友好度 68/100
slackapi/java-slack-sdk#1672 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
enhancement project:slack-api-model
難度 3/5 半天 新手友好度 75/100
slackapi/java-slack-sdk#1657 · 2 則留言 ·
維護者通常 1 天內回覆
-
Upgrade Jetty可能已有人在做 @skrcode 於 63 天前認領。 未關閉auto-triage-skip dependencies good first issue
難度 4/5 3-5 天 新手友好度 45/100
slackapi/java-slack-sdk#1567 · 4 則留言 ·
維護者通常 1 天內回覆
-
auto-triage-skip discussion enhancement
難度 3/5 1-2 天 新手友好度 35/100
slackapi/java-slack-sdk#1535 · 5 則留言 ·
維護者通常 1 天內回覆
-
auto-triage-skip question untriaged
難度 5/5 一週以上 新手友好度 25/100
slackapi/java-slack-sdk#1528 · 7 則留言 ·
維護者通常 1 天內回覆
查看 slackapi/java-slack-sdk 的全部 Issue
相似的 Issue
-
5.0.x backport enhancement
難度 2/5 1-3 小時 新手友好度 63/100
spring-cloud/spring-cloud-function#1507 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
open-learning-exchange/myplanet#18484 ·
維護者通常 1 天內回覆
-
ai-driven-fuzzing bug claude Minor
難度 2/5 1-3 小時 新手友好度 66/100
linagora/twake-calendar-side-service#1417 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 74/100
line/armeria#7109 · 3 個 reaction ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
open-feature/java-sdk-contrib#1966 ·
維護者通常 1 天內回覆