@@ -21,6 +21,7 @@ import { QuartoJSONSchema } from "./js-yaml-schema.ts";
2121import { createSourceContext } from "../yaml-validation/errors.ts" ;
2222import { tidyverseInfo } from "../errors.ts" ;
2323import { InternalError } from "../error.ts" ;
24+ import { isCircular } from "../is-circular.ts" ;
2425
2526// deno-lint-ignore no-explicit-any
2627type TreeSitterParse = any ;
@@ -268,23 +269,10 @@ export function buildJsYamlAnnotation(mappedYaml: MappedString) {
268269 ) ;
269270 }
270271
271- // console.log(results[0]);
272- try {
273- JSON . stringify ( results [ 0 ] ) ; // this is here so that we throw on circular structures
274- } catch ( e ) {
275- if ( e . message . match ( "invalid string length" ) ) {
276- // https://github.com/quarto-dev/quarto-cli/issues/10504
277- // It seems to be relatively easy to hit string length limits in
278- // JSON.stringify. Since this call is only here to check for circular
279- // structures, we chose to ignore this error, even though it's not
280- // ideal
281- } else if ( e . message . match ( / c i r c u l a r s t r u c t u r e / ) ) {
282- throw new InternalError (
283- `Circular structure detected in parsed yaml: ${ e . message } ` ,
284- ) ;
285- } else {
286-
287- }
272+ if ( isCircular ( results [ 0 ] ) ) {
273+ throw new InternalError (
274+ `Circular structure detected in yaml` ,
275+ ) ;
288276 }
289277 return postProcessAnnotation ( results [ 0 ] ) ;
290278}
0 commit comments