LG-8050 | Attempts API timestamp parsing fix#7316
Conversation
Match what the IRS is actually sending Sneaks in an unrelated change to the generated filename to accommodate a request they had. changelog: Improvements, Attempts API, Change timestamp parsing for IRS
| Time.strptime(timestamp_param, '%Y-%m-%dT%H:%M:%S%z') | ||
| date_fmt = timestamp_param.match?('\.') ? '%Y-%m-%dT%H:%M:%S.%N%z' : '%Y-%m-%dT%H:%M:%S%z' | ||
|
|
||
| Time.strptime(timestamp_param, date_fmt) |
There was a problem hiding this comment.
Hokay, so. I wanted to accommodate both timestamp formats (what everything we built is using, and what the IRS is sending). This felt like the easiest way to accommodate that -- just check for a literal dot.
We could do a more elegant regexp, or potentially nested exception handling -- catch ArgumentError and try again with the other format, potentially catching it again, but that felt gross. This seemed least bad, but I wouldn't put this on my resume as a shining example of the best code I've ever written.
|
|
||
| filename = | ||
| "FCI-#{IdentityConfig.store.irs_attempt_api_csp_id}_#{formatted_time}_#{digest}.dat.gz.hex" | ||
| "FCI-Logingov_#{formatted_time}_#{digest}.dat.gz.hex" |
There was a problem hiding this comment.
This was "LOGIN.gov".
The IRS wanted it to be "Logingov" because they worried that the ".gov" would be treated as a file extension. I don't think we need to accommodate a variable CSP ID, so I just hardcoded it. The "FCI-" portion is already hardcoded.
Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
🎫 Ticket
https://cm-jira.usa.gov/browse/LG-8050 + https://cm-jira.usa.gov/browse/LG-8051
🛠 Summary of changes
The IRS is sending us timestamps with milliseconds in them, which currently generates an HTTP 422. Just accept this format.
I'm working in a related change to what we call the generated file, based on their request.