Open
Description
Describe the issue
I am facing an issue that when having a really large swagger.json (15+ thousand lines, size was 7.538 MB), the json stringify or parse function will fail with the error message Error: Max. depth level of JSON reached at position xxx
.
To Reproduce
Steps to reproduce the behavior:
- Have a really large swagger.json
- Let docfx parse it
- See the error message output
Expected behavior
docfx is able to parse the swagger.json without issues.
Context (please complete the following information):
- OS: Windows 11 (Build 22631.4460)
- Docfx version: 2.77.0
Additional context
A swagger.json with around 10k lines doesn't fail. The issue seems to be caused by an underlying JS library that has the limit, but I am not a specialist there to be able to tell what exactly is going on. I am not able to share the swagger.json due to NDA. Full stacktrace:
<path to swagger.json>: error ApplyTemplatePreprocessorError: Error transforming model "<path to raw model of swagger.json>" generated from "<path to swagger.json>" using "RestApi.html.primary.js". Error running Transform function inside template preprocessor: Error: Max. depth level of JSON reached at position 889036
at parse RestApi.common.js:297:22
at addDefinition (definition, definitions) RestApi.common.js:297:22
at addComplexTypeMetadata (child, definitions) RestApi.common.js:339:9
at forEach RestApi.common.js:88:72
at forEach RestApi.common.js:88:17
at forEach RestApi.common.js:87:13
at RestApi.common.js:86:9
DocumentException: Error transforming model "<path to raw model of swagger.json>" generated from "<path to swagger.json>" using "RestApi.html.primary.js". Error running Transform function inside template preprocessor: Error: Max. depth level of
JSON reached at position 889036
at parse RestApi.common.js:297:22
at addDefinition (definition, definitions) RestApi.common.js:297:22
at addComplexTypeMetadata (child, definitions) RestApi.common.js:339:9
at forEach RestApi.common.js:88:72
at forEach RestApi.common.js:88:17
at forEach RestApi.common.js:87:13
at RestApi.common.js:86:9
DocumentException: Error transforming model "<path to raw model of swagger.json>" generated from "<path to swagger.json>" using "RestApi.html.primary.js". Error running Transform function inside template preprocessor: Error: Max. depth
level of JSON reached at position 889036
at parse RestApi.common.js:297:22
at addDefinition (definition, definitions) RestApi.common.js:297:22
at addComplexTypeMetadata (child, definitions) RestApi.common.js:339:9
at forEach RestApi.common.js:88:72
at forEach RestApi.common.js:88:17
at forEach RestApi.common.js:87:13
at RestApi.common.js:86:9
InvalidPreprocessorException: Error running Transform function inside template preprocessor: Error: Max. depth level of JSON reached at position 889036
at parse RestApi.common.js:297:22
at addDefinition (definition, definitions) RestApi.common.js:297:22
at addComplexTypeMetadata (child, definitions) RestApi.common.js:339:9
at forEach RestApi.common.js:88:72
at forEach RestApi.common.js:88:17
at forEach RestApi.common.js:87:13
at RestApi.common.js:86:9
at object TransformModel(object model) in PreprocessorWithResourcePool.cs:81
at object TransformModel(object model) in Template.cs:95
at ManifestItem Transform(InternalManifestItem item) in TemplateModelTransformer.cs:98
at ManifestItem Transform(InternalManifestItem item) in TemplateModelTransformer.cs:115
at void <ProcessCore>b__0(InternalManifestItem item) in TemplateProcessor.cs:194
at void <RunAll>b__0(TElement s) in DocumentExceptionExtensions.cs:80
at void RunAll<TElement>(IEnumerable<TElement> elements, Action<TElement> action, int parallelism) in DocumentExceptionExtensions.cs:89
at void RunAll<TElement>(IReadOnlyList<TElement> elements, Action<TElement> action, int parallelism) in DocumentExceptionExtensions.cs:60
at List<ManifestItem> ProcessCore(List<InternalManifestItem> items, ApplyTemplateSettings settings, IDictionary<string, object> globals) in TemplateProcessor.cs:189
at List<ManifestItem> Process(List<InternalManifestItem> manifest, ApplyTemplateSettings settings, IDictionary<string, object> globals) in TemplateProcessor.cs:88
at List<ManifestItem> ProcessTemplate() in ManifestProcessor.cs:182
at void Process() in ManifestProcessor.cs:53
at void Handle(List<HostService> hostServices, int maxParallelism) in LinkPhaseHandler.cs:32
at Manifest Build(DocumentBuildParameters parameters, IMarkdownService markdownService) in SingleDocumentBuilder.cs:67
at void Build(IList<DocumentBuildParameters> parameters, string outputDirectory) in DocumentBuilder.cs:122
at void BuildDocument(BuildJsonConfig config, BuildOptions options, TemplateManager templateManager, string baseDirectory, string outputDirectory, string templateDirectory) in DocumentBuilderWrapper.cs:42
at string Exec(BuildJsonConfig config, BuildOptions options, string configDirectory, string outputDirectory) in RunBuild.cs:39
at void <Execute>b__0() in DefaultCommand.cs:51
at int Run(LogOptions options, Action run) in CommandHelper.cs:48
at int Execute(CommandContext context, Options options) in DefaultCommand.cs:31
at Task<int> Execute(CommandContext context, CommandSettings settings) in CommandOfT.cs:40
at async Task<int> Execute(CommandTree leaf, CommandTree tree, CommandContext context, ITypeResolver resolver, IConfiguration configuration) in CommandExecutor.cs:166
Metadata
Metadata
Assignees
Labels
No labels