-
Notifications
You must be signed in to change notification settings - Fork 8
Use invariant culture for AWS date formatting #158
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
Conversation
Updated date formatting and parsing in AWS authentication to explicitly use System.Globalization.CultureInfo.InvariantCulture and DateTimeStyles.AssumeUniversal. This ensures consistent behavior regardless of system locale. Closes BLD-298
WalkthroughCulture-invariant formatting was applied to AWS date strings, and server time parsing in the signature-expired retry path was adjusted to treat parsed times as UTC using DateTimeStyles.AssumeUniversal. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant AWSAuth as AWS Auth Helper
participant AWSSvc as AWS Service
rect rgba(200,220,255,0.25)
note right of AWSAuth: Build signed request (culture-invariant date formatting)
Client->>AWSAuth: Prepare request
AWSAuth->>AWSSvc: Send signed request
end
alt Success
AWSSvc-->>AWSAuth: 200 OK
AWSAuth-->>Client: Response
else Signature expired
AWSSvc-->>AWSAuth: 403 SignatureExpired + ServerTime
note right of AWSAuth: Parse ServerTime as UTC (AssumeUniversal)
AWSAuth->>AWSSvc: Re-sign and retry
AWSSvc-->>AWSAuth: Response
AWSAuth-->>Client: Response
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks (4 passed, 1 warning)❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs (2)
178-186
: Treating server time as UTC is correct; add a bounds check and (optionally) AdjustToUniversalCurrent substring can throw if AWS changes error text shape. Guard length before Substring; also consider AdjustToUniversal (harmless with ‘Z’ input) for completeness.
- var idx = responseContent.LastIndexOf('('); - if (idx > -1) - { - var parsedTimeString = responseContent.Substring(idx + 1, amzDate.Length); - var serverTime = DateTime.ParseExact(parsedTimeString, amzDateFormat, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal); + var idx = responseContent.LastIndexOf('('); + if (idx > -1 && idx + 1 + amzDate.Length <= responseContent.Length) + { + var parsedTimeString = responseContent.Substring(idx + 1, amzDate.Length); + var serverTime = DateTime.ParseExact( + parsedTimeString, + amzDateFormat, + System.Globalization.CultureInfo.InvariantCulture, + System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal);
229-231
: Hex formatting: align with invariant push (nit)AppendFormat defaults to current culture. It’s already safe for “x2”, but using InvariantCulture keeps the file consistently culture-agnostic.
- _ = hex.AppendFormat("{0:x2}", b); + _ = hex.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "{0:x2}", b);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-test-cov
🔇 Additional comments (1)
Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs (1)
135-136
: Invariant culture for SigV4 timestamps — LGTMUsing CultureInfo.InvariantCulture for amzDate and dateStamp is correct and prevents locale/calendar-induced breakage.
Updated date formatting and parsing in AWS authentication to explicitly use System.Globalization.CultureInfo.InvariantCulture and DateTimeStyles.AssumeUniversal. This ensures consistent behavior regardless of system locale.
Closes BLD-298
PR-Codex overview
This PR focuses on improving the date formatting in the
AWS.cs
file by ensuring that date strings are consistently formatted usingSystem.Globalization.CultureInfo.InvariantCulture
.Detailed summary
amzDate
anddateStamp
to useCultureInfo.InvariantCulture
for string formatting.serverTime
parsing to includeDateTimeStyles.AssumeUniversal
for accurate time interpretation.Summary by CodeRabbit
Bug Fixes
Reliability