-
Notifications
You must be signed in to change notification settings - Fork 390
[fix] Automatically fix malformed node def translations #4042
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
Conversation
| - name: Clean null values from translations | ||
| run: | | ||
| # Remove null entries from outputs arrays in all translated files | ||
| find src/locales/*/nodeDefs.json -not -path "*/en/*" -exec sed -i 's/,\s*null//g; s/null,\s*//g; s/\[\s*null\s*\]/[]/g' {} \; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this generated? It's doing some weird stuff. Where are we going to get ,\s*null?
For any bash script using sed, verification is reasonably important. It looks like the middle script is the only one that's actually wanted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is generated. I'm currently testing by recreating conditions of issue detailed in #3967 and verifying it correctly solves the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More context:
Where the null values come from:
The null values appear in the translated locale files (not the English source) when the OpenAI
translation service encounters timing issues. Specifically, when node outputs are removed/added between
script runs, the translation service sometimes produces malformed arrays like:
"outputs": [
null,
null,
null,
{
"name": "normal"
}
]
Instead of the correct object format:
"outputs": {
"0": {
"name": "imagen"
},
"1": {
"name": "mask"
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah fair enough! Must be doing something weird with arrays and having them serialise as objects. Originally couldn't find anything that matched when I searched.
2fc1427 to
01a6ac4
Compare
|
Changes:
|
Adds cleanup step to i18n workflow to remove null entries that can occur when translation service encounters timing issues with node output changes. Also adds concise documentation for the node definition translation script.
01a6ac4 to
14ae679
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming you're verifying by diffing the output of test vs the actual expected output, this looks great.
If the actual file contents haven't been checked, they should be. Reason is it looks like it works by:
- Removing nulls/undefined from the array and stuffing it back as an object
- If this invalidates the entire array, it should replace all outputs 👍
However if it simply adds any missing values (like it does elsewhere in i18n), then the first output or three will have the (completely) wrong translation. 🙅
|
This commit is entirely the result of running the script: 3bee3c5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect claude write ts script under scripts/ and call it via tsx like other files under scripts/. Maybe add that instruction to CLAUDE.md?
@christian-byrne Reverting this for now. This script must be reviewed using the diff of a 100% valid, working run. |
This reverts commit ec4ced2.
|
What's expected/correct behavior that the script should do in that screenshot? |
|
It's only setting "index 5" on an "array object" - which is a bit weird to begin with but we know about that. It's missing indices 0-4 (removed by script). So they'll be So {
"0": {name:"n1"},
"1": {name:"n2"},
// ... 2, 3, and 4 go here
"5": {name:"sanc_banana"}
} |
|
Or if it really only has one output, not 6, then just Edit: Or if it's only translating input 6, then that's fine. But in this instance, it's not - the english section had all outputs listed. This is one of a few styles of broken things I noticed. You can just get a working example (i18n had no timeouts) and a broken example of the same changes from another run, then diff. Is there a reason not to do this? It's basically the only thing worth verifying here. |
|
I need to start from beginning to better understand original error that Terry fixed and work from there. |
|
The immediately apparent solution is to fill the mistaken null values generated by lobe-i18n with the translations from a previous version if it exists (otherwise the untranslated name). It will require re-running the emulation and field extraction, as the order of outputs may have genuinely switched since last time the script ran. And it requires accessing the history of the translation file and parsing the relevant fields to determine if a previous translation can be used. It is tempting to rewrite the translation automation process using better/maintained tooling. There are so many better tools for this, it doesn't make sense why we need to use a obscure open-source tool when we can easily make our own agent. But even in that case you may still want this type of validation process anyway. Lowest effort solution is to accept (presumably) small margin of error with current tool and just add null check here: ComfyUI_frontend/src/services/litegraphService.ts Lines 203 to 220 in f7093f6
in which case the lost translation is just simply lost but everything still works/renders otherwise. |
|
Can't we just delete corrupt entries and rerun i18n? |
|
Actually let's just break this down today quickly. |
|
The corruption is from lobe-cli itself |

Adds cleanup step to i18n workflow to remove null entries that can occur when translation service encounters timing issues with node output changes.
┆Issue is synchronized with this Notion page by Unito