Skip to content

LG-13570 we were parsing JSON as JSON and that was bad#10846

Merged
ajfarkas merged 2 commits intomainfrom
LG-13570_JSON-parse-dropoff-report-error
Jun 21, 2024
Merged

LG-13570 we were parsing JSON as JSON and that was bad#10846
ajfarkas merged 2 commits intomainfrom
LG-13570_JSON-parse-dropoff-report-error

Conversation

@ajfarkas
Copy link
Contributor

🎫 Ticket

Link to the relevant ticket:
LG-13570

🛠 Summary of changes

We were seeing the error: no implicit conversion of Array into String on the dropoff report.
This was because we're implicitly converting our configs to their described type in identity_config.rb, and then trying to parse that JSON with JSON.parse in drop_off_report.rb.

This PR comments our code and removes the offending parse.

📜 Testing Plan

Provide a checklist of steps to confirm the changes.

  • Updated tests catch double-parsing
  • Report should go out as planned.

Thanks to @h-m-m and @nprimak for working on this bug.

Comment on lines +7 to +8
JSON.parse'[{"emails":["ursula@example.com"],
"issuers":["urn:gov:gsa:openidconnect.profiles:sp:sso:agency_name:app_name"]}]'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably easier to have this as a ruby literal than managing a string

Suggested change
JSON.parse'[{"emails":["ursula@example.com"],
"issuers":["urn:gov:gsa:openidconnect.profiles:sp:sso:agency_name:app_name"]}]'
[
{
"emails" => ["ursula@example.com"],
"issuers" => ["urn:gov:gsa:openidconnect.profiles:sp:sso:agency_name:app_name"],
},
]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this is to point out that this line is a String in our config, and we auto-parse it to JSON.
The comment above is an important addition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config parsing is standard across our app, and intended to abstract away the minutiae of parsing the string values.

But if we really want to parse a string in this spec,, I think that the multi-line string literal here is really hard to parse, it would be much clearer using heredoc syntax and adding in the optional parens:

Suggested change
JSON.parse'[{"emails":["ursula@example.com"],
"issuers":["urn:gov:gsa:openidconnect.profiles:sp:sso:agency_name:app_name"]}]'
JSON.parse(<<~STR)
[{"emails":["ursula@example.com"],"issuers":["urn:gov:gsa:openidconnect.profiles:sp:sso:agency_name:app_name"]}]
STR

changelog: Bug Fixes, Reports, Resolve double-parsing JSON in Dropoff report (LG-13570)
@ajfarkas ajfarkas merged commit f827d2b into main Jun 21, 2024
@ajfarkas ajfarkas deleted the LG-13570_JSON-parse-dropoff-report-error branch June 21, 2024 14:01
ajfarkas added a commit that referenced this pull request Jun 21, 2024
* LG-13570 we were parsing JSON as JSON and that was bad

* LG-13570 lint corrections

changelog: Bug Fixes, Reports, Resolve double-parsing JSON in Dropoff report (LG-13570)
ajfarkas added a commit that referenced this pull request Jun 24, 2024
* LG-13570 we were parsing JSON as JSON and that was bad

* LG-13570 lint corrections

changelog: Bug Fixes, Reports, Resolve double-parsing JSON in Dropoff report (LG-13570)
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.

2 participants