File tree Expand file tree Collapse file tree
src/tools/accessiblity-utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { apiClient } from "../../lib/apiClient.js" ;
22import { parse } from "csv-parse/sync" ;
3+ import logger from "../../logger.js" ;
34
45type 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" ] ,
You can’t perform that action at this time.
0 commit comments