Skip to content

Commit 1294108

Browse files
Merge pull request #341 from SavioBS629/accessibility-scan-fix
fix: invalid record length
2 parents de89919 + 6176d18 commit 1294108

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/tools/accessiblity-utils/report-parser.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { apiClient } from "../../lib/apiClient.js";
22
import { parse } from "csv-parse/sync";
3+
import logger from "../../logger.js";
34

45
type SimplifiedAccessibilityIssue = {
56
issue_type: string;
@@ -34,10 +35,23 @@ export async function parseAccessibilityReportFromCSV(
3435
if (!res.ok) throw new Error(`Failed to download report: ${res.statusText}`);
3536
const text =
3637
typeof res.data === "string" ? res.data : JSON.stringify(res.data);
37-
const all: SimplifiedAccessibilityIssue[] = parse(text, {
38-
columns: true,
39-
skip_empty_lines: true,
40-
}).map((row: any) => ({
38+
39+
let parsed: any[];
40+
try {
41+
parsed = parse(text, {
42+
columns: true,
43+
skip_empty_lines: true,
44+
relax_column_count_less: true,
45+
});
46+
} catch (err) {
47+
logger.error(
48+
`[AccessibilityReport] CSV parse failed (${text.length} chars): ${
49+
err instanceof Error ? err.message : String(err)
50+
}`,
51+
);
52+
throw err;
53+
}
54+
const all: SimplifiedAccessibilityIssue[] = parsed.map((row: any) => ({
4155
issue_type: row["Issue type"],
4256
component: row["Component"],
4357
issue_description: row["Issue description"],

0 commit comments

Comments
 (0)