[BUG] Problem with Timestamp
See original GitHub issueLibrary 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:
- Created a year ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
It must be writing a datetime value to the entity somewhere. The repro steps, as written above, work as expected.