-
Notifications
You must be signed in to change notification settings - Fork 78
Fix culture-dependent date formatting using RFC 1123 for HTTP headers and sortable ISO 8601 for InnerError #1441
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
base: main
Are you sure you want to change the base?
Conversation
…ormat Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot The original request was to use the ISO-8601 format
|
@copilot The original request was to use the ISO-8601 format |
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
|
@copilot I was wrong. Revert back to using the RFC format you had previously |
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
|
@copilot OK, there's some nuance. When the date is used with response headers, it needs to be in the |
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Updated to use RFC 1123 format for HTTP Date headers and ISO 8601 format for InnerError.Date property. Both formats now use the same |
waldekmastykarz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot in all occurrences, replace the o format with s
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
| var entry = new HarEntry | ||
| { | ||
| StartedDateTime = currentTime.ToString("o"), | ||
| StartedDateTime = currentTime.ToString("s"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this needs to be o to match the HAR format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted HarGeneratorPlugin to use "o" format for HAR specification compliance. The HAR format requires full ISO 8601 with timezone information. Commit: 8ea43c5
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a culture-dependent date formatting bug where Graph API mock responses displayed dates in different formats depending on the system's regional settings (e.g., 13/11/2025 14:30:00 in French vs 11/13/2025 2:30 PM in US English).
- Replaces culture-dependent
DateTime.Now.ToString(CultureInfo.CurrentCulture)with standardized, culture-invariant formats - HTTP Date headers now use RFC 1123 format (
"r") per RFC 7231 standard - InnerError.Date properties use ISO 8601 sortable format (
"s") for consistency with Microsoft Graph
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| MockResponsePlugin.cs | Updated HTTP Date header formatting to RFC 1123 format for mock responses |
| GraphMockResponsePlugin.cs | Updated HTTP Date header formatting to RFC 1123 format for both individual and batch mock responses (2 locations) |
| RetryAfterPlugin.cs | Updated both HTTP Date headers (RFC 1123) and InnerError.Date (ISO 8601) in throttling error responses, using same DateTime value for consistency |
| RateLimitingPlugin.cs | Updated both HTTP Date headers (RFC 1123) and InnerError.Date (ISO 8601) in rate limiting error responses, using same DateTime value for consistency |
| GraphRandomErrorPlugin.cs | Updated HTTP Date headers (RFC 1123) and InnerError.Date (ISO 8601) in random error responses (2 locations), using same DateTime value for consistency |
Fix GraphMockResponsePlugin Date Format Culture Issue
HTTP Date headers and InnerError date properties in mocked Graph responses were formatted using the system's culture settings, causing inconsistent output across different locales (e.g.,
13/11/2025 14:30:00in French vs11/13/2025 2:30 PMin US).Changes
DateTime.Now.ToString(CultureInfo.CurrentCulture)with culture-invariant formats"r") - standard HTTP Date header format per RFC 7231"s") - sortable date/time pattern without timezone"o") - per HAR specification requirementsDateTime.Nowvalue to ensure consistencyGraphMockResponsePlugin.cs(2 locations - HTTP headers only)MockResponsePlugin.cs(1 location - HTTP headers only)RateLimitingPlugin.cs(1 location - HTTP headers and InnerError)GraphRandomErrorPlugin.cs(2 locations - HTTP headers and InnerError)RetryAfterPlugin.cs(1 location - HTTP headers and InnerError)HarGeneratorPlugin.cs(1 location - HAR file generation with"o"format)Format Details
RFC 1123 (HTTP headers):
Sun, 16 Nov 2025 11:16:59 GMTISO 8601 sortable (InnerError.Date):
2025-11-16T11:16:59ISO 8601 round-trip (HAR format):
2025-11-16T11:59:30.1234567+00:00Example
Verification
✅ Build successful with no warnings
✅ All formats verified as culture-invariant
✅ Same DateTime value ensures consistency between header and body
✅ HAR format complies with specification
Fixes #1436
Original prompt
This section details on the original issue you should resolve
<issue_title>[BUG]: GraphMockResponsePlugin Mocked JSON date format depends on local machine culture settings</issue_title>
<issue_description>### Description
When using GraphMockResponsePlugin in Dev Proxy, the dates contained in the mocked JSON responses are formatted according to the operating system's regional culture settings. This causes inconsistent output across different environments. Since Dev Proxy intends to mock Microsoft Graph responses, date formats should be predictable and aligned with Microsoft Graph’s ISO-8601 conventions.
Expected behaviour
All mocked Microsoft Graph date/time fields should be serialized using a consistent culture-invariant ISO-8601 format (e.g. 2025-11-01T14:30:00Z), independent of the host machine’s locale/region settings. Like the sample response present in the documentation https://learn.microsoft.com/en-us/graph/throttling
Actual behaviour
Date/time values in mocked JSON responses vary depending on the OS regional settings. For example:
01/11/2025 14:30:00 on a French machine
11/01/2025 2:30 PM on a US machine
This leads to non-deterministic behavior.
Steps to reproduce
Configure Dev Proxy with GraphMockResponsePlugin enabled.
Run Dev Proxy on a machine with French regional settings.
Observe the different date fields in mocked responses
Run the same proxy on a machine with US regional settings.
Compare the JSON responses and note that date formats differ between environments.
Dev Proxy Version
1.3
Operating system (environment)
Windows
Shell
PowerShell
Configuration file
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.3.0/rc.schema.json",
"plugins": [
{
"name": "GraphSelectGuidancePlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll"
},
{
"name": "GraphBetaSupportGuidancePlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"urlsToWatch": [
"https://graph.microsoft.com/beta/",
"https://graph.microsoft.us/beta/",
"https://dod-graph.microsoft.us/beta/",
"https://microsoftgraph.chinacloudapi.cn/beta/"
]
},
{
"name": "GraphConnectorGuidancePlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"urlsToWatch": [
"https://graph.microsoft.com//external/connections//schema",
"https://graph.microsoft.us//external/connections//schema",
"https://dod-graph.microsoft.us//external/connections//schema",
"https://microsoftgraph.chinacloudapi.cn//external/connections//schema"
]
},
{
"name": "GraphSdkGuidancePlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll"
},
{
"name": "ODataPagingGuidancePlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll"
},
{
"name": "GraphClientRequestIdGuidancePlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll"
},
{
"name": "GraphRandomErrorPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "graphRandomErrorsPlugin"
},
{
"name": "ExecutionSummaryPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "executionSummaryPlugin"
}
],
"urlsToWatch": [
"https://graph.microsoft.com/v1.0/",
"https://graph.microsoft.com/beta/",
"https://graph.microsoft.us/v1.0/",
"https://graph.microsoft.us/beta/",
"https://dod-graph.microsoft.us/v1.0/",
"https://dod-graph.microsoft.us/beta/",
"https://microsoftgraph.chinacloudapi.cn/v1.0/",
"https://microsoftgraph.chinacloudapi.cn/beta/"
],
"graphRandomErrorsPlugin": {
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.3.0/graphrandomerrorplugin.schema.json",
"allowedErrors": [
429,
500,
502,
503,
504,
507
],
"rate": 50
},
"executionSummaryPlugin": {
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.3.0/executionsummaryplugin.schema.json",
"groupBy": "url"
},
"labelMode": "text",
"logLevel": "information"
}
Additional Info
No response</issue_description>
Comments on the Issue (you are @copilot in this section)
@waldekmastykarz Good catch and a clear bug on our end. We'll get to fix it asap. Sorry for the trouble and thanks for pointing it out.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.