Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SharePoint Custom Fields (Single line of text) - Gets cast to Python Pendulam DateTime #653

Closed
nikhilmakan02 opened this issue Apr 8, 2024 · 3 comments · Fixed by microsoft/kiota-serialization-json-python#348
Assignees
Labels
area:serialization Focused on functional modules of the product bug Something isn't working priority:p0 Blocking issue. Loss of critical functions eg security/privacy violation. Bug SLA<=48hrs

Comments

@nikhilmakan02
Copy link

Hi Everyone, doing a simple call to a SharePoint Document library to return the custom metadata fields related to a file. What's interesting is I can set the column type to 'Single line of text' in SharePoint but if I put certain numbers into the column it returns as a datetime object.

If I put text in the field on SharePoint it returns correctly as text or even if I put enough numbers it returns as text as well.

In the example below the Doc_ID column in SharePoint contains the numbers 1212.
image
image

result = await (
        client.drives.by_drive_id(drive_id)
        .items.by_drive_item_id(drive_item_id)
        .list_item.get()
    )

print(result.fields.additional_data["Doc_x0020_ID"])
print(type(result.fields.additional_data["Doc_x0020_ID"]))

Output:

1212-01-01 00:00:00+00:00
<class 'pendulum.datetime.DateTime'>

This seems like unexpected behavior?

@georgethomasii
Copy link

I am seeing a similar issues when querying entraid attributes. Any value that has a 4-digit numerical value is being returned as a datetime object instead of a string. If I get the raw http response the value is returned as a string correctly. It would be great if this was looked into and resolved as I prefer not to have to get the native HTTPX response.

@andrueastman andrueastman added the bug Something isn't working label Apr 15, 2024
@shemogumbe shemogumbe added area:serialization Focused on functional modules of the product priority:p2 Medium. For a p2 bug, generally have a work-around. Bug SLA <=30 days labels Apr 23, 2024
@shemogumbe
Copy link
Collaborator

Hello, and thanks for continued use of the SDK and for raising this.
As we look into our serialization to give a consistent behaviour, would you cast the result to a string/datetime object for now:

  • Pendulum to string
# Cast Pendulum DateTime to string
pendulum_datetime_string = pendulum_datetime.to_iso8601_string()
print("Pendulum DateTime as string (ISO 8601 format):", pendulum_datetime_string)
  • string to pendulum
# Parse the string to Pendulum DateTime object
pendulum_datetime = pendulum.parse(pendulum_datetime_if_string)

@nikhilmakan02
Copy link
Author

@shemogumbe I am not really sure how that is helpful? Are you suggesting I cast this to a string then truncate the string to get the 4 digit value. That sounds like a messy solution to be honest.

I have actually just implemented @georgethomasii suggestion to just get the raw response and get the metadata more reliably there.

@shemogumbe shemogumbe self-assigned this Aug 23, 2024
@shemogumbe shemogumbe added priority:p0 Blocking issue. Loss of critical functions eg security/privacy violation. Bug SLA<=48hrs and removed priority:p2 Medium. For a p2 bug, generally have a work-around. Bug SLA <=30 days labels Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:serialization Focused on functional modules of the product bug Something isn't working priority:p0 Blocking issue. Loss of critical functions eg security/privacy violation. Bug SLA<=48hrs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants