Enhance ExtraArgs sanitization and backend recovery logic

- Introduced the `clean_extra_args` function to filter out unsafe CLI flags and comment garbage from `ExtraArgs`, improving backend configuration integrity.
- Updated the `repair_extra_args_on_disk` function to rewrite corrupted `ExtraArgs` lines in the FDS file, ensuring cleaner backend settings.
- Enhanced the `recover_errored_backends` function to utilize the new sanitization logic, preserving valid `ExtraArgs` during backend reconfiguration.
- Improved the `sanitize_backends_fds` function to drop comment garbage and retain valid entries, enhancing overall backend management.
- Added tests to validate the new sanitization behavior, ensuring robustness in handling `ExtraArgs` during backend operations.
This commit is contained in:
Leonid Pershin
2026-08-21 11:56:53 +03:00
parent b9059cd275
commit 491816b679
3 changed files with 169 additions and 41 deletions
+16
View File
@@ -189,6 +189,22 @@ def test_sanitize_does_not_eat_newline_on_bare_empty(tmp_path, monkeypatch):
assert backends.read_text(encoding="utf-8") == original
def test_sanitize_drops_comment_garbage_extra_args(tmp_path, monkeypatch):
mod = _load()
backends = tmp_path / "Backends.fds"
junk = (
'\tExtraArgs: "#If unchecked, the system will automatically add some '
'relevant arguments to the comfy launch."\n'
"\tStartScript: /mnt/x/main.py\n"
)
backends.write_text(junk, encoding="utf-8")
monkeypatch.setattr(mod, "BACKENDS", backends)
assert mod.sanitize_backends_fds() is True
text = backends.read_text(encoding="utf-8")
assert "unchecked" not in text
assert "StartScript: /mnt/x/main.py" in text
def test_ensure_absolute_start_script(tmp_path, monkeypatch):
mod = _load()
data = tmp_path