question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Problem with Timestamp

See original GitHub issue

Library name and version

Azure.Data.Tables 12.6.1

Describe the bug

I am trying to add new entity to the table. Here is my code:

var table = tableServiceClient.GetTableClient(tableName);
Response response = table.AddEntity(entity);

Expected behavior

It should add entity to the table.

Actual behavior

Unhandled exception. System.NotSupportedException: DateTime 3/1/2013 12:00:00 AM has a Kind of Unspecified. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.
   at Azure.Core.TypeFormatters.ToString(DateTime value, String format)
   at Azure.Core.Utf8JsonWriterExtensions.WriteObjectValue(Utf8JsonWriter writer, Object value)
   at Azure.Data.Tables.TableRestClient.CreateInsertEntityRequest(String table, Nullable`1 timeout, Nullable`1 responsePreference, IDictionary`2 tableEntityProperties, QueryOptions queryOptions)
   at Azure.Data.Tables.TableRestClient.InsertEntity(String table, Nullable`1 timeout, Nullable`1 responsePreference, IDictionary`2 tableEntityProperties, QueryOptions queryOptions, CancellationToken cancellationToken)
   at Azure.Data.Tables.TableClient.AddEntity[T](T entity, CancellationToken cancellationToken)
   at Models.StorageContext.AddEntity[T](String tableName, T entity) in C:\Users\David Babayan\Source\repos\SqlToStorageTable\Models\StorageContext.cs:line 29
   at Program.<Main>$(String[] args) in C:\Users\David Babayan\Source\repos\SqlToStorageTable\Program.cs:line 35

Reproduction Steps

TableServiceClient tableServiceClient = new TableServiceClient(
  new Uri("tableUrl"),
  new TableSharedKeyCredential( "accountName", "accountKey")
);
TableEntity entity = new("partitionValue", "rowKey")
{
  {"Column1", "Value1"},
  {"Column2", "Value2"}
};
string tableName = "TableName";
var table = tableServiceClient.GetTableClient(tableName);
Response response = table.AddEntity(entity);

Environment

dotnet --info results: Version: 6.0.400 Commit: 7771abd614 OS Name: Windows OS Version: 10.0.22000 OS Platform: Windows RID: win10-x64

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
davidbabayancommented, Aug 23, 2022

As I learned the problem was not with timestamp property but with another property which was holding date. The documentation does not mention that any property containing date or time should have Utc kind. Maybe it is good idea to mention it there.

0reactions
christothescommented, Aug 22, 2022

I wrote a console application which takes data from a database and tries to write it to the table. My code is one page I am sure it does not write anywhere.

It must be writing a datetime value to the entity somewhere. The repro steps, as written above, work as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Year 2038 problem
The year 2038 problem is a time formatting bug in computer systems with representing times after 03:14:07 UTC on 19 January 2038. An...
Read more >
Time stamp bug
The iPhone SE Crashes due to time stamp bug. ... My iPad is showing the wrong date and time on the status bar...
Read more >
The 2286 Bug. Unix timestamps represent time as…
Unix timestamps represent time as seconds elapsed since January 1, 1970. The current-ish Unix timestamp as of this writing is 1453665679.
Read more >
There is a bug in timestamps while searching, here is the ...
There is a bug in timestamps while searching, here is the explanation on what the problem is, to help fix it (90% sure)....
Read more >
Timestamp field items are affected by 2038 bug
Problem /Motivation The timestamp field item storage type is [signed] int, which is currently 4 bytes in most DB systems (MySQL and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found