fix: handle malformed JSONL lines gracefully in post-buffered-inline-comments
Wrap per-line JSON.parse in try-catch so a single truncated/malformed entry (e.g. from an OOM mid-write) skips with a warning instead of aborting the entire batch and dropping all comments. Co-authored-by: vtmocanu <vtmocanu@users.noreply.github.com>
This commit is contained in:
1 parent
ec394266fc
commit
c80d3be21a
1 file changed
+8
-1
@@ -155,7 +155,14 @@ async function main() {
|
||||
const comments: BufferedComment[] = raw
|
||||
.split("\n")
|
||||
.filter(Boolean)
|
||||
.map((line) => JSON.parse(line));
|
||||
.flatMap((line) => {
|
||||
try {
|
||||
return [JSON.parse(line) as BufferedComment];
|
||||
} catch {
|
||||
console.log(`::warning::Skipping malformed JSONL line: ${line.slice(0, 120)}`);
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
if (comments.length === 0) {
|
||||
console.log("No buffered inline comments");
|
||||
|
||||
Reference in new issue
Block a user