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

[BUG] TableEntity.GetDateTime throws InvalidOperationException #25323

Closed
j055 opened this issue Nov 15, 2021 · 7 comments · Fixed by #25804
Closed

[BUG] TableEntity.GetDateTime throws InvalidOperationException #25323

j055 opened this issue Nov 15, 2021 · 7 comments · Fixed by #25804
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Tables

Comments

@j055
Copy link

j055 commented Nov 15, 2021

Describe the bug
TableEntity.GetDateTime throws InvalidOperationException. Cannot return System.Nullable`1[System.DateTime] type for a System.DateTimeOffset typed property.

The date was added using TableEntity.Add, e.g.

MyEntity entity = new MyEntity();
entity.DateTime = DateTime.UtcNow;
TableEntity tableEntity = new TableEntity();
tableEntity.Add(nameof(entity.DateTime), entity.DateTime);

Expected behavior
TableEntity.GetDateTime should return a valid Nullable<DateTime> without error.

Actual behavior (include Exception or Stack Trace)

at Azure.Data.Tables.TableEntity.EnforceType(Type requestedType, Type givenType)
at Azure.Data.Tables.TableEntity.GetValue(String key, Type type)   
at Azure.Data.Tables.TableEntity.GetValue[T](String key)   
at Azure.Data.Tables.TableEntity.GetDateTime(String key)   at UserQuery.Map(TableEntity tableEntity), line 62   
at System.Linq.Enumerable.SelectListIterator`2.ToList()   
at UserQuery.Main(), line 21

To Reproduce

  • Create an Azure storage account
  • Use TableClient.UpsertEntityAsync with a TableEntity containing a System.DateTime property
  • Use TableClient.GetEntityAsync<TableEntity> to retrieve entity and TableEntity.GetDateTime to parse date.

Exception is thrown.

As above

Environment:

  • Azure.Data.Tables 12.3.0
  • Hosting platform Windows 10
@ghost ghost added needs-triage This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 15, 2021
@jsquire jsquire added Client This issue points to a problem in the data-plane of the library. needs-team-attention This issue needs attention from Azure service team or SDK team Tables labels Nov 15, 2021
@jsquire
Copy link
Member

jsquire commented Nov 15, 2021

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Nov 15, 2021
@christothes
Copy link
Member

Hi @j055
If entity.DateTime is typed as a DateTimeOffset, then this behavior is by design.

ex.

var t = new TableEntity();
t.Add("DateTime", DateTime.UtcNow);
t.Add("DateTimeOffset", DateTimeOffset.UtcNow);
Console.WriteLine(t.GetDateTime("DateTime")); // prints 11/15/2021 4:29:22 PM
Console.WriteLine(t.GetDateTimeOffset("DateTime")); // throws
Console.WriteLine(t.GetDateTimeOffset("DateTimeOffset")); // prints 11/15/2021 4:29:22 PM +00:00
Console.WriteLine(t.GetDateTime("DateTimeOffset")); // throws

@christothes christothes added the issue-addressed The Azure SDK team member assisting with this issue believes it to be addressed and ready to close. label Nov 15, 2021
@ghost
Copy link

ghost commented Nov 15, 2021

Hi @j055. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

@ghost ghost removed the needs-team-attention This issue needs attention from Azure service team or SDK team label Nov 15, 2021
@ghost
Copy link

ghost commented Nov 22, 2021

Hi @j055, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

@ghost ghost closed this as completed Nov 22, 2021
@j055
Copy link
Author

j055 commented Nov 23, 2021

@christothes

I've updated To Reproduce above. You need a storage account to reproduce. Then update and retrieve when the entity contains a DateTime property. Exception thrown.

@ghost ghost reopened this Nov 23, 2021
@ghost ghost added needs-team-attention This issue needs attention from Azure service team or SDK team and removed issue-addressed The Azure SDK team member assisting with this issue believes it to be addressed and ready to close. labels Nov 23, 2021
@j055
Copy link
Author

j055 commented Nov 23, 2021

/unresolve

@christothes
Copy link
Member

Thanks for the additional information. I see the problem and will be working on a fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Tables
Projects
None yet
3 participants