Skip to content

Add proper JSON escaping in crash report templates #905

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

Merged
merged 1 commit into from
Mar 22, 2025

Conversation

Kartikayy007
Copy link
Contributor

@Kartikayy007 Kartikayy007 commented Mar 20, 2025

Fix JSON format errors in crash reports

Description

This PR fixes JSON format errors in crash reports due to improper escaping or were missing quotes entirely, causing parsing errors referenced in issue.

fixes: #903

Changes

  • Added proper quotes around template expressions
  • Added proper escaping for double quotes with \"
  • Added proper formatting for newlines as \n

Example

Before:

{
  "samples": [
    {
      "coverage_report": "#",
      "stacktrace": "/stacktrace",
      "target_binary": "/target_binary",
      "reproducer": "/artifacts",
      "run_log": "run.log",
      "source_code": ,
      "model": "claude-3-opus-20240229"
    }
  ]
}

After:

{
  "samples": [
    {
      "coverage_report": "#",
      "stacktrace": "SIGSEGV\ncrash at 0x004a3f21\n#0 0x004a3f21 in function()",
      "target_binary": "/target_binary",
      "reproducer": "/artifacts",
      "run_log": "run.log",
      "source_code": "#include <stdint.h>\n#include <stdlib.h>\nint LLVMFuzzerTestOneInput() {...}",
      "model": "claude-3-opus-20240229"
    }
  ]
}

@Kartikayy007
Copy link
Contributor Author

@DonggeLiu does this seem fine?

@DonggeLiu
Copy link
Collaborator

Thanks @Kartikayy007.
Yep this looks good.
I will create a PR for us to experiment with it on more projects.

Meanwhile, would @Ekam219's suggestions sound good to you?

@DonggeLiu DonggeLiu changed the base branch from main to exp-905 March 22, 2025 22:30
@DonggeLiu DonggeLiu merged commit d591fbc into google:exp-905 Mar 22, 2025
4 of 5 checks passed
@DonggeLiu
Copy link
Collaborator

Experiment launched in #918

For follow-up changes, let's create new PRs based on google:exp-905 : )

@Kartikayy007
Copy link
Contributor Author

Kartikayy007 commented Mar 23, 2025

Thanks @Kartikayy007. Yep this looks good. I will create a PR for us to experiment with it on more projects.

Meanwhile, would @Ekam219's suggestions sound good to you?

yes sounds good and can be implemented, Its already implemented in #906

@Ekam219
Copy link

Ekam219 commented Mar 23, 2025

Thanks @Kartikayy007! That sounds great. I've already created the PR with the update. Let me know if you have any feedback!"

DonggeLiu pushed a commit that referenced this pull request Mar 24, 2025
# Fix JSON format errors in crash reports

## Description
This PR fixes JSON format errors in crash reports due to improper
escaping or were missing quotes entirely, causing parsing errors
referenced in issue.

fixes: #903 

## Changes
* Added proper quotes around template expressions
* Added proper escaping for double quotes with `\"`
* Added proper formatting for newlines as `\n`

## Example
Before:
```json
{
  "samples": [
    {
      "coverage_report": "#",
      "stacktrace": "/stacktrace",
      "target_binary": "/target_binary",
      "reproducer": "/artifacts",
      "run_log": "run.log",
      "source_code": ,
      "model": "claude-3-opus-20240229"
    }
  ]
}
```

After:
```json
{
  "samples": [
    {
      "coverage_report": "#",
      "stacktrace": "SIGSEGV\ncrash at 0x004a3f21\n#0 0x004a3f21 in function()",
      "target_binary": "/target_binary",
      "reproducer": "/artifacts",
      "run_log": "run.log",
      "source_code": "#include <stdint.h>\n#include <stdlib.h>\nint LLVMFuzzerTestOneInput() {...}",
      "model": "claude-3-opus-20240229"
    }
  ]
}
```
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.

Fix JSON formatting in crash.json template
3 participants