-
Notifications
You must be signed in to change notification settings - Fork 78
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: Failed to stringify code #111
Comments
@jehna please help me |
Can you run humanify using |
I'm trying right now |
Do you have any suggestions on what I can do to fix the problem? |
Hmm. Seems like an issue with some of the dependencies, at least that error does not originate from humanify's code. |
So what can I do as a solution? Solving this code is very important to me |
How can I send you error details |
Whoops, closed this by accident. You could check which part of the bundle throws the error, that would help |
When I check, the "transformFromAstAsync" function in the "@babel/core" package gives an error. Since I'm not familiar with the package, I have no idea how to fix the problem. I would be grateful if you could help |
Please help me |
Will you help? |
@Yusufkulcu thanks for the additional info, but unfortunately I'm not able to respond to bigger work immediately (not being paid for doing ppen source etc) |
I think I'll be able to investigate more within a few weeks when I have some time |
I understood. I would be very happy if I know when the study is concluded. We hope that it will be concluded as soon as possibleI understood. I would be very happy if I know when the study is concluded. Hoping to conclude it as soon as possible 😊 |
@Yusufkulcu I haven't looked too deeply into this, but I suspect the issue is likely not going to be directly within Looking up that humanify/src/plugins/local-llm-rename/visit-all-identifiers.ts Lines 57 to 62 in 2ac5d25
It looks like it throws that when the result from Depending on your skill at debugging, it might be useful to see what the value of Depending on the sensitivity of the code you're running this on, it could also be useful if you're able to attach the code that consistently triggers this area; even better if you're first able to reduce it to a minimal example that triggers the error; as that would make it a lot easier for others to help debug/understand what might be causing it. |
I didn't understand exactly what I was supposed to do:( |
@Yusufkulcu At a minimum, if you are able to attach the code you're trying to decrypt, that would be really useful to help narrow things down. |
Yes, you are right, I have attached the file below. Github I uploaded it to my Google drive account because it doesn't allow javascript file uploading. https://drive.google.com/file/d/1H9_g6L32xMchrpi-dIRksz7MyQkmWm2a/view?usp=drivesdk |
@Yusufkulcu Thanks. If you just rename the .js file to .txt that would usually let you upload it directly to GitHub as well. |
Thanks for the info. I reloaded it as txt. I will be waiting for your help. It's an important project for me |
@Yusufkulcu Thanks for that. I ran it through the web version of Depending on your use case, I wonder if you might be able to use that unpacked/unmangled version as a starting point for your analysis; even though it doesn't have the 'nice variable renames' that |
@Yusufkulcu Looking at your screenshot from #111 (comment), it looks like the error is occuring on file 18: Looking at the code where this happens, it seems to be within Lines 6 to 30 in c2e0be6
Since even with Looking at the contents of ⇒ cat output/1.js | wc -m
0 As part of the main humanify/src/commands/openai.ts Lines 26 to 30 in c2e0be6
When run as The humanify/src/plugins/local-llm-rename/visit-all-identifiers.ts Lines 57 to 61 in c2e0be6
Which is called by the humanify/src/plugins/openai/openai-rename.ts Lines 6 to 38 in c2e0be6
Presumably, with an empty file as input, that would result in an empty ast, which when passed to Given the check that ends up throwing the error you're seeing is looking for a falsy value in humanify/src/plugins/local-llm-rename/visit-all-identifiers.ts Lines 57 to 62 in c2e0be6
@Yusufkulcu @jehna So the above seems to be the debugging as to the 'why' of what is going on; though I'm not familiar enough with the codebase to suggest where the best point of implementing the fix is. If I was to suggest the most minimal/localised fix, it would be to the Though an argument could also be made that filtering out empty/similar files at the So I still think the best fix is probably within In fact, in looking through related issues, this just seems to be a variation of the same root cause that I raised in this issue: I also think the general CLI output should be improved to explain what is happening better. eg. a message before running These issues also seem to tangentially relate to some aspect of this latter suggestion: |
Thanks for the suggested solution. It works largely without "beautifying variable" values. But my goal is to change it completely. It seems to take a long time to decode the files in the "outputs" folder one by one with Humanify. Is there a shortcut to this? |
@Yusufkulcu Do you mean that the process takes a long time in general? Or that having to manually run it against each file takes a long time? If the latter, you could probably extract them with Actually.. it will probably still be a bit slower because of the startup boilerplate, and then trying to run While it's not currently a feature, if you're going to need to be re-running the variable renaming process on future versions of the same code, this feature request would probably also be relevant to you: @jehna It might be a neat/useful feature to be able to run Edit: I split this last part into its own issue: |
Thank you for your detailed explanation. I'm going to try the parsed source code separately by writing a script that implements the humanify command. I have one more question. What is the reason why the "Webcrack" package breaks the code into pieces. I divide it into many files in the Outputs folder and I don't know what they are. I wonder if you can explain that. Thank you in advance |
@Yusufkulcu It might actually be quicker for you to just clone the I haven't tried it, but a quick/dirty hack fix could just be to add an Something like: export async function unminify(
filename: string,
outputDir: string,
plugins: ((code: string) => Promise<string>)[] = []
) {
ensureFileExists(filename);
const bundledCode = await fs.readFile(filename, "utf-8");
const extractedFiles = await webcrack(bundledCode, outputDir);
for (let i = 0; i < extractedFiles.length; i++) {
console.log(`Processing file ${i + 1}/${extractedFiles.length}`);
const file = extractedFiles[i];
const code = await fs.readFile(file.path, "utf-8");
+ if (code) {
const formattedCode = await plugins.reduce(
(p, next) => p.then(next),
Promise.resolve(code)
);
verbose.log("Input: ", code);
verbose.log("Output: ", formattedCode);
await fs.writeFile(file.path, formattedCode);
+ }
+ else {
+ verbose.log(`Skipping empty file ${i + 1} (${file.path})`);
+ }
}
} While this wouldn't really be suited for a proper fix, it should hopefully be enough to do what you need to work around this bug in the meantime.
@Yusufkulcu The original source file you provided is a webpack bundle of code (or similar), where the original many code files have been combined into a single file. When |
Thanks for the suggestion, it doesn't give that error anymore, but now I'm getting another error. I get the following error in file 63. I've added the original file and the file where I got the error below. It's a pretty long mistake, so I added some more pictures. |
@Yusufkulcu I'm glad that workaround helped get around the first issue :)
That new error you're running into seems to now be the same/similar to the errors being discussed in this issue: You might like to try the potential solution I described in this comment, RE: cloning the |
For context/continuity, @j4k0xb has raised 2 bugfix PR's for the bugs identified in this issue: |
I trade using chatgpt. I am getting the error shown in the screenshot. The file size is large (7mb on average) and the number of lines is high (134881 lines). What is the problem? Can you help me? This is very important to me
The text was updated successfully, but these errors were encountered: