microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

[Client bug]: EducationAssignment doesn't serialize assignDateTime

Open
#1,820 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug: metadata OpenApi
Dominant language
C#
Stars
789
Forks
264
Avg merge
15h 17m
Merged PRs (30d)
3

Description

Describe the bug
When trying to patch the EducationAssignment.AssignDateTime via the graph service client, the value won't be set.

To Reproduce

        [Fact]
        public void EducationAssignmentSerializesAssignDateTime()
        {
            var tokenCredentials = Azure.Core.DelegatedTokenCredential.Create(null);
            var serviceClient = new GraphServiceClient(tokenCredentials);

            var source = new EducationAssignment
            {
                AssignDateTime = new DateTime(2023, 4, 13, 13, 45, 00),
            };

            var requestInfo = serviceClient
                .Education
                .Classes["classId"]
                .Assignments["assignmentId"]
                .ToPatchRequestInformation(source);

            var memory = new MemoryStream();
            requestInfo.Content.CopyTo(memory);
            var bytes = memory.ToArray();
            var json = Encoding.UTF8.GetString(bytes);

            // Currently json is only "{}"
            Assert.Contains("assignDateTime", json);
        }

Expected behavior
This property (and also some others) should be writeable via the SDK. According to the documenation this value is writeable (at least under specific conditions):

Date the assignment should be published to students. Cannot be edited after the assignment has been published.

But the current serialize code shows, that not all properties are written, that are read.

Workaround
Fortunately the bag AdditionalData can be misused to get the value back to graph, but this should be fixed ASAP:

source.AdditionalData["assignDateTime"] = source.AssignDateTime;

Client version
5.5.0

Additional context
Currently I just stumbled across this specific property, that is accidentially marked as read-only (or what is the reason, that this property can be deserialized, but not serialized?). And potentially someone from the education team has to review all meta information to ensure, that we won't find the next missing property after this one has been fixed and released.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Microsoft.Graph/Generated/Models/EducationAssignment.cs, comparing the serialization code with the deserialization code for AssignDateTime. Use the reproduction test from the issue to verify the generated patch request content. Done means the request JSON contains assignDateTime and the regression test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.