ListRecord.Field array-shaped `message` still fails in the production GsonFactory (follow-up to #1587)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
Hướng nghiên cứu
Bắt đầu với GsonFactory.registerTypeAdapters và GsonListViewGroupingFactory; issue đề xuất chuyển GsonListRecordFieldFactory vào slack-api-model/src/main/java/com/slack/api/util/json/ và đăng ký nó trong factory production. Kiểm tra adapter test hiện có và ListRecordFieldTest để biết cách xử lý mong đợi đối với đối tượng đơn và mảng. Hoàn thành khi GsonFactory production phân tích thành công cả hai dạng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 602
- Fork
- 235
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của slackapi/java-slack-sdk
-
Upgrade JettyCó thể đã có người làm @skrcode đã nhận 40 ngày trước. Đang mởauto-triage-skip dependencies good first issue
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
slackapi/java-slack-sdk#1567 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
auto-triage-skip discussion enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
slackapi/java-slack-sdk#1535 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Workflows, Slack Apps and formsĐang mởauto-triage-skip question untriaged
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
slackapi/java-slack-sdk#1528 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update okhttp to 5.xĐang mởauto-triage-skip dependencies project:slack-api-client project:slack-app-backend
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
slackapi/java-slack-sdk#1500 · 11 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Table Block SupportĐang mởauto-triage-skip enhancement project:slack-api-model
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
slackapi/java-slack-sdk#1499 · 4 bình luận · 3 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của slackapi/java-slack-sdk
Issue tương tự
-
BoxAttachmentMulti parsing leaks IOException / ArrayIndexOutOfBoundsException on malformed content instead of IllegalArgumentExceptionCó thể đã có người làm @Kshot3000 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
ergoplatform/ergo-appkit#272 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
utopia-rise/godot-jvm#1004 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
spring-projects/spring-grpc#442 ·