Guard convertToSingleHost against deeply nested JSON config files#223
Open
ayush-meghwani-28 wants to merge 1 commit into
Open
Conversation
convertToSingleHost.js rewrites config files (launch.json / package.json / tasks.json) by reading, modifying, and writing them back with JSON.stringify. Node's JSON.stringify is recursive and throws 'RangeError: Maximum call stack size exceeded' on extremely deeply nested input, producing an opaque failure. Wrap the write-back serialization in a small helper that catches that RangeError and rethrows a clear message naming the file. Normal template content is unaffected.
Author
|
/azurepipeline run |
|
Commenter does not have sufficient privileges for PR 223 in repo OfficeDev/Office-Addin-TaskPane-JS |
Contributor
|
/azurepipeline run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
millerds
approved these changes
Jul 7, 2026
Contributor
|
/azurepipeline run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for your pull request! Please provide the following information.
Change Description:
convertToSingleHost.jsreads config files (launch.json / package.json / tasks.json), modifies them, and writes them back withJSON.stringify(content, null, 2). Node'sJSON.stringifyis recursive, so a config file containing extremely deeply nested JSON causes an opaqueRangeError: Maximum call stack size exceeded(the earlierJSON.parsesucceeds because it is iterative).This PR wraps the write-back serialization in a small
stringifyJson(content, fileName)helper that catches thatRangeErrorand rethrows a clear, actionable message naming the file being written, instead of an opaque stack overflow. Normal template content is unaffected.This mirrors the fix already merged in OfficeDev/Excel-Custom-Functions#504, applied here because
convertToSingleHost.jsis duplicated across the template repos.Do these changes impact any npm scripts commands (in package.json)? (e.g., running 'npm run start')
=> No
Do these changes impact VS Code debugging options (launch.json)?
=> No
Do these changes impact template output? (e.g., add/remove file, update file location, update file contents)
=> No
Do these changes impact documentation? (e.g., a tutorial on https://docs.microsoft.com/en-us/office/dev/add-ins/overview/office-add-ins)
=> No
Validation/testing performed:
Unable to update ".vscode/launch.json": its JSON content is too deeply nested.node --check convertToSingleHost.jspasses.