Skip to content

[Feature Flags] Fix ISO 8601 date parsing to support variable precision#8089

Closed
leoromanovsky wants to merge 2 commits intoDataDog:masterfrom
leoromanovsky:leo/fix-iso8601-date-parsing
Closed

[Feature Flags] Fix ISO 8601 date parsing to support variable precision#8089
leoromanovsky wants to merge 2 commits intoDataDog:masterfrom
leoromanovsky:leo/fix-iso8601-date-parsing

Conversation

@leoromanovsky
Copy link
Copy Markdown
Contributor

@leoromanovsky leoromanovsky commented Jan 22, 2026

The date parser was using TryParseExact with a fixed 3-digit millisecond format, causing PARSE_ERROR for dates with 6-digit microsecond precision (e.g., "2025-09-23T15:48:37.235982Z") sent by the backend.

Changed to use DateTime.TryParse with DateTimeStyles.RoundtripKind which correctly handles all valid ISO 8601 date formats including:

  • No fractional seconds: 2020-01-01T00:00:00Z
  • 1-7 digit fractional seconds (beyond 7 digits truncated by .NET)

Added comprehensive unit tests for various date precisions and invalid date handling. Also added microsecond-date-test flag and test cases to the bundled test data.

Summary of changes

Reason for change

Implementation details

Test coverage

Associating a new system test (also discovered this condition in java): DataDog/system-tests#6087

Other details

The date parser was using TryParseExact with a fixed 3-digit millisecond
format, causing PARSE_ERROR for dates with 6-digit microsecond precision
(e.g., "2025-09-23T15:48:37.235982Z") sent by the backend.

Changed to use DateTime.TryParse with DateTimeStyles.RoundtripKind which
correctly handles all valid ISO 8601 date formats including:
- No fractional seconds: 2020-01-01T00:00:00Z
- 1-7 digit fractional seconds (beyond 7 digits truncated by .NET)

Added comprehensive unit tests for various date precisions and invalid
date handling. Also added microsecond-date-test flag and test cases
to the bundled test data.
@leoromanovsky
Copy link
Copy Markdown
Contributor Author

Recreated as first-party PR from DataDog/dd-trace-dotnet: #8094

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant