Entity.createFromDiscriminatorValue incorrectly deserializes #microsoft.graph.user as com.microsoft.graph.beta.models.security.User
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu với discriminator factory của models/Entity.java được tạo ở các dòng được tham chiếu và so sánh các import cùng ánh xạ kiểu của nó với DirectoryObject::createFromDiscriminatorValue. Chạy bản tái hiện KiotaJsonSerialization được cung cấp, sau đó thêm coverage hồi quy cho #microsoft.graph.user và kiểm tra xem các ánh xạ discriminator khác có cùng sự mơ hồ hay không.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
In current beta version, when trying to deserialize a #microsoft.graph.user from JSON using KiotaJsonSerialization.deserialize(json, Entity::createFromDiscriminatorValue), it's returned as a com.microsoft.graph.beta.models.security.User instance.
This is because only one of com.microsoft.graph.beta.models.User and com.microsoft.graph.beta.models.security.User is imported the latter), and classes are referenced without fully qualified name.
See https://github.com/microsoftgraph/msgraph-beta-sdk-java/blob/3612a3a8958cc35b0be7626b966008ea99a031af/src/main/java/com/microsoft/graph/beta/generated/models/Entity.java#L2075 and https://github.com/microsoftgraph/msgraph-beta-sdk-java/blob/3612a3a8958cc35b0be7626b966008ea99a031af/src/main/java/com/microsoft/graph/beta/generated/models/Entity.java#L2326
There are probably other cases like this one.
Expected behavior
KiotaJsonSerialization.deserialize(json, Entity::createFromDiscriminatorValue) should return a com.microsoft.graph.beta.models.User instance for #microsoft.graph.user objects.
How to reproduce
This test
//passes
assertEquals(com.microsoft.graph.beta.models.User.class, KiotaJsonSerialization.deserialize("""
{
"@odata.type": "#microsoft.graph.user"
}
""", DirectoryObject::createFromDiscriminatorValue).getClass());
//KO
assertEquals(com.microsoft.graph.beta.models.User.class, KiotaJsonSerialization.deserialize("""
{
"@odata.type": "#microsoft.graph.user"
}
""", Entity::createFromDiscriminatorValue).getClass());
will fail with
org.opentest4j.AssertionFailedError:
Expected :class com.microsoft.graph.beta.models.User
Actual :class com.microsoft.graph.beta.models.security.User
SDK Version
6.51.0
Latest version known to work for scenario above?
No response
Known Workarounds
Pass a more precise ParsableFactory, like DirectoryObject::createFromDiscriminatorValue, like in the reproduction test.
Debug output
Configuration
No response
Other information
I found an old bug in Kiota that might be related (it was marked as fixed though): https://github.com/microsoft/kiota/issues/1801
- Ngôn ngữ chính
- Java
- Star
- 32
- Fork
- 14
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 6
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 microsoftgraph/msgraph-beta-sdk-java
-
type:bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
upgrade to okhttp 5 Đang mởenhancement help wanted
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
dependency:metadata status:waiting-for-dependency
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
microsoftgraph/msgraph-beta-sdk-java#1181 · 5 bình luận · 1 reaction ·
-
type:bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
microsoftgraph/msgraph-beta-sdk-java#1162 · 1 bình luận · 1 reaction ·
-
Cannot update sponsors of user Đang mởNeeds: attention :wave: Needs: Attention 👋 Type: Question
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
microsoftgraph/msgraph-beta-sdk-java#1002 · 2 bình luận ·
Tất cả issue của microsoftgraph/msgraph-beta-sdk-java
Issue tương tự
-
Bug Java Platform: Java
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
getsentry/sentry-java#6138 · 1 bình luận ·
-
bug needs triage p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 bình luận ·
-
[LNG prod] Release 2.4.6 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/rocketmq-dashboard#4654 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100