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/,并在生产工厂中注册它。查看现有的测试适配器和 ListRecordFieldTest,了解对单个对象和数组的预期处理方式。生产环境中的 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
- 派生
- 235
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 8
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
slackapi/java-slack-sdk 的其他 Issue
-
Upgrade Jetty可能已有人在做 @skrcode 于 41 天前认领。 未关闭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 天内回复
-
auto-triage-skip dependencies project:slack-api-client project:slack-app-backend
难度 4/5 3-5 天 新手友好度 48/100
slackapi/java-slack-sdk#1500 · 11 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
auto-triage-skip enhancement project:slack-api-model
难度 3/5 1-2 天 新手友好度 68/100
slackapi/java-slack-sdk#1499 · 4 条评论 · 3 个 reaction ·
维护者通常 1 天内回复
查看 slackapi/java-slack-sdk 的全部 Issue
相似的 Issue
-
`RedisList.reversed()` view returns an empty `range` and `trim` removes all elements可能已有人在做 @CCCLL 今天认领。 未关闭status: waiting-for-triage
难度 2/5 1-3 小时 新手友好度 72/100
spring-projects/spring-data-redis#3461 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
devops-thiago/ThrillhouseBot#1093 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
wimdeblauwe/htmx-spring-boot#205 ·
-
[BUG] 增量 SSE 解析器未识别单独 CR 换行,导致事件无法及时交付可能已有人在做 @king-wwwhhh 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
langchain4j/langchain4j#6669 ·
维护者通常 1 天内回复
-
enhancement tech-debt
难度 2/5 1-3 小时 新手友好度 78/100
Albertinesilva/backend-engineering-journey-java-springboot#41 ·