Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with JSON Parsing and Undefined Property Access When Unminifying JavaScript with Humanify #22

Closed
abdurrahim11 opened this issue Jul 30, 2024 · 5 comments

Comments

@abdurrahim11
Copy link

I am facing problem while running one of my big script first everything is fine then after some time it gives below error

my minify js link: https://drive.google.com/file/d/1QHHRw_YKbYwgf7rbT8R8qP6Uh5BxNZ4l/view?usp=sharing

echo "OPENAI_TOKEN=sk-proj-MsUzhNo4jhbzk9zziiKET.............." > .env && npm start -- -o admin.js admin.min.js
export OPENAI_TOKEN="sk-proj-MsUzhNo4jhbzk9zziiKET.............." && npm start -- -o admin.js admin.min.js
OPENAI_TOKEN=sk-proj-MsUzhNo4jhbzk9zziiKET.............. npm start -- -o admin.js admin.min.js
npm start -- --key="sk-proj-MsUzhNo4jhbzk9zziiKET.............." -o admin.js admin.min.js
undefined:351
...
^

SyntaxError: Unexpected token '.', ..."E" },
...
]
}" is not valid JSON
at JSON.parse ()
at codeToVariableRenames (/home/abdurrahimcoder/humanify-main/src/openai/openai.ts:76:59)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at (/home/abdurrahimcoder/humanify-main/src/openai/openai.ts:21:23)
at async Promise.all (index 1)
at mapPromisesParallel (/home/abdurrahimcoder/humanify-main/src/openai/run-promises-in-parallel.ts:17:5)
at client.createChatCompletion.model (/home/abdurrahimcoder/humanify-main/src/openai/openai.ts:20:5)
at (/home/abdurrahimcoder/humanify-main/src/index.ts:68:25)

Node.js v20.15.1

/home/abdurrahimcoder/humanify-main/src/openai/rename-variables-and-functions.ts:17
const rename = toRename.find((r) => r.name === path.node.name);
^

TypeError: unknown file: Cannot read properties of undefined (reading 'name')
at (/home/abdurrahimcoder/humanify-main/src/openai/rename-variables-and-functions.ts:17:49)
at Array.find ()
at PluginPass.Identifier (/home/abdurrahimcoder/humanify-main/src/openai/rename-variables-and-functions.ts:17:35)
at newFn (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/visitors.ts:292:14)
at _call (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/path/context.ts:35:20)
at call (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/path/context.ts:20:17)
at NodePath.visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/path/context.ts:94:31)
at visitQueue (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:144:16)
at visitMultiple (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:98:17)
at visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:174:19)
at traverseNode (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/traverse-node.ts:40:17)
at NodePath.visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/path/context.ts:101:33)
at visitQueue (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:144:16)
at visitSingle (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:108:19)
at visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:176:19)
at traverseNode (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/traverse-node.ts:40:17)
at NodePath.visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/path/context.ts:101:33)
at visitQueue (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:144:16)
at visitSingle (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:108:19)
at visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:176:19)
at traverseNode (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/traverse-node.ts:40:17)
at NodePath.visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/path/context.ts:101:33)
at visitQueue (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:144:16)
at visitSingle (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:108:19)
at visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:176:19)
at traverseNode (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/traverse-node.ts:40:17)
at NodePath.visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/path/context.ts:101:33)
at visitQueue (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:144:16)
at visitMultiple (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:98:17)
at visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:174:19)
at traverseNode (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/traverse-node.ts:40:17)
at NodePath.visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/path/context.ts:101:33)
at visitQueue (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:144:16)
at visitSingle (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:108:19)
at visit (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/context.ts:176:19)
at traverseNode (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/traverse-node.ts:40:17)
at traverse (/home/abdurrahimcoder/humanify-main/node_modules/@babel/traverse/src/index.ts:82:15)
at transformFile (/home/abdurrahimcoder/humanify-main/node_modules/@babel/core/src/transformation/index.ts:120:13)
at transformFile.next ()
at run (/home/abdurrahimcoder/humanify-main/node_modules/@babel/core/src/transformation/index.ts:47:12)
at run.next ()
at transform (/home/abdurrahimcoder/humanify-main/node_modules/@babel/core/src/transform.ts:29:20)
at transform.next ()
at step (/home/abdurrahimcoder/humanify-main/node_modules/gensync/index.js:261:32)
at /home/abdurrahimcoder/humanify-main/node_modules/gensync/index.js:273:13
at async.call.result.err.err (/home/abdurrahimcoder/humanify-main/node_modules/gensync/index.js:223:11)
at /home/abdurrahimcoder/humanify-main/node_modules/gensync/index.js:50:45
at step (/home/abdurrahimcoder/humanify-main/node_modules/gensync/index.js:287:14)
at /home/abdurrahimcoder/humanify-main/node_modules/gensync/index.js:273:13
at async.call.result.err.err (/home/abdurrahimcoder/humanify-main/node_modules/gensync/index.js:223:11) {
code: 'BABEL_TRANSFORM_ERROR'
}

@jehna
Copy link
Owner

jehna commented Jul 30, 2024

SyntaxError: Unexpected token '.', ..."E" },

This is very probably the same issue as #12

@jehna
Copy link
Owner

jehna commented Aug 11, 2024

This should now be fixed in v2 since there's the long awaited JSON mode with the new structured outputs. Please take a look and repoen if anything comes up

@tkreuder
Copy link

@jehna Thanks a lot for providing that tool!!

I using humanify 2.1.2 but still face the issue.

code: 'BABEL_PARSE_ERROR',
reasonCode: 'UnexpectedToken',
loc: Position { line: 17261, column: 14, index: 542664 },
pos: 542664,
syntaxPlugin: undefined

@0xdevalias
Copy link

code: 'BABEL_PARSE_ERROR',
reasonCode: 'UnexpectedToken',

@tkreuder I'm not 100%, but I believe this may be a separate issue to the above. It sounds like the error is happening during the babel parsing of the code, not the JSON parsing. To debug it further, I suspect the code you're trying to to unminify will be needed (or at the very least, tracking down what part of the code is being referenced there as being unexpected. Given it's happening in the babel area of things, there's also a chance that this may be a bug/unsupported edge case in webcrack (which this tool uses for unminification)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants