-
Notifications
You must be signed in to change notification settings - Fork 521
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
🌱 Format the JSON output #2251
🌱 Format the JSON output #2251
Conversation
@@ -124,6 +124,7 @@ func (r *ScorecardResult) AsJSON2(showDetails bool, | |||
} | |||
|
|||
encoder := json.NewEncoder(writer) | |||
encoder.SetIndent("", " ") |
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.
There are tools like BigQuery transfers that expect the JSON output to be on a single line. I'm not sure it's our job to prettify the result (breaking change). I fully agree we need more human-friendly results for the badges; but is this the right place for the fix?
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.
This is a start. @azeemshaikh38 will this cause breaking charges for BigQuery?
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.
For BQ we JSONify the results in a different file (under cron/). Some users may be using this output, though.
If you only want these changes for BQ data, I think you need to update cron/
and the GH Action instead, not this file.
I would be OK with that since it's not exposed publicly.
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.
+1. Very likely that some users get broken by this.
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.
OK, If that is the case. I will close it 👍
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.
So @azeemshaikh38 If I change the BQ will it be an issue?
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.
@azeemshaikh38 We discussed this in our bi-weekly. We agreed formatting the JSON output shouldn't be an issue.
Stale pull request message |
b938178
to
c0b947b
Compare
c0b947b
to
d8e5851
Compare
- This helps with this issue https://github.com/ossf/scorecard/issues/2243 Signed-off-by: naveensrinivasan <[email protected]>
Signed-off-by: naveensrinivasan <[email protected]>
d8e5851
to
e1dd80e
Compare
@@ -86,6 +86,7 @@ type jsonScorecardResultV2 struct { | |||
// AsJSON exports results as JSON for new detail format. | |||
func AsJSON(r *pkg.ScorecardResult, showDetails bool, logLevel log.Level, writer io.Writer) error { | |||
encoder := json.NewEncoder(writer) | |||
encoder.SetIndent("", " ") |
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.
If I change the BQ will it be an issue?
As far as I know, yes. BQ expects newline delimited JSON and refers to the linked spec.
"Each Line is a Valid JSON Value". I can try to confirm with a test upload, but I expect this to break the BQ transfer. Yeah this breaks BQ transfer:
Error while reading data, error message: Failed to parse JSON: Unexpected end of string; Unexpected end of string;
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.
The files in the API bucket don't get transferred as far as I can tell. Would a pretty-print argument (bool?) be acceptable?
@@ -265,6 +265,7 @@ func fillJSONRawResults(r *jsonScorecardRawResult, raw *checker.RawResults) erro | |||
// AsRawJSON exports results as JSON for raw results. | |||
func AsRawJSON(r *pkg.ScorecardResult, writer io.Writer) error { | |||
encoder := json.NewEncoder(writer) | |||
encoder.SetIndent("", " ") |
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.
same as above comment
Stale pull request message |
This PR fell off, but for future attempts I'm not sure this was the right place to implement it. The webapp unmarshalls the file, so I don't think the output in the bucket is what matters. |
Signed-off-by: naveensrinivasan [email protected]