Skip to content

[HOLD for payment 2023-01-26] Make getMergeLogsAsJSON more robust #13649

Description

@roryabraham

Problem

We've got some code here that logs commit message using git log and then sanitizes the output and turns it to JSON.

This code is fickle, because any symbols included in commit messages that break JSON.parse will cause an error. We've seen a number of instances of this happening over the last year, and it seems likely to continue happening until we nail this code down a bit more robustly.

Solution

  1. Extract a small module to src/libs/sanitizeStringForJSON, that escapes special characters from a string to prepare it to be used in JSON.parse
  2. Use this library in GitUtils.getMergeLogsAsJSON
  3. Add a new set of Jest unit tests to cover sanitizeStringForJSON.

Here are some suggestions to get you started.

Metadata

Metadata

Assignees

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionEngineeringImprovementItem broken or needs improvement.ReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions