5 Commits

Author SHA1 Message Date
Jedrzej Kosinski
2001646f78 Switch deploy-environment value convention from underscores to dashes
Default value is now 'local-git' (was 'local_git'). Dashes are easier to type and more conventional in HTTP-header-adjacent identifiers. Tests updated accordingly.

Amp-Thread-ID: https://ampcode.com/threads/T-019df26e-96f4-7518-94da-0e4263680e3c
Co-authored-by: Amp <amp@ampcode.com>
2026-05-04 07:20:22 -07:00
Jedrzej Kosinski
22186b3dae Use functools.cache instead of manual global cache
Replaces the hand-rolled '_cached_value' module global with @functools.cache, which is the standard Python idiom for memoization. Tests now use the built-in get_deploy_environment.cache_clear() to reset between cases.

Amp-Thread-ID: https://ampcode.com/threads/T-019df26e-96f4-7518-94da-0e4263680e3c
Co-authored-by: Amp <amp@ampcode.com>
2026-05-04 06:55:54 -07:00
Jedrzej Kosinski
06e416bd0d Bound .comfy_environment read at 128 bytes; add unit tests
Defense-in-depth: cap readline() so a malformed or maliciously-large single-line file cannot blow up memory before the value is sanitized.

Adds tests-unit/deploy_environment_test.py covering: missing file fallback, basic read, whitespace strip, multi-line (only first line used), empty + whitespace-only files, control-char stripping (header-injection protection), non-ASCII stripping, 128-byte read cap, cache stickiness, and OSError fallback.

Amp-Thread-ID: https://ampcode.com/threads/T-019df26e-96f4-7518-94da-0e4263680e3c
Co-authored-by: Amp <amp@ampcode.com>
2026-05-04 06:53:40 -07:00
Jedrzej Kosinski
f350a175c3 Change deploy environment read failure log from warning to error
Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Amp-Thread-ID: https://ampcode.com/threads/T-019db205-95da-7654-ace4-40f12a5f6e69
Co-authored-by: Amp <amp@ampcode.com>
2026-04-21 14:51:51 -07:00
Jedrzej Kosinski
e7fbb3c2db Add deploy environment header to partner node API calls
Read a .comfy_environment file from the ComfyUI base directory to
determine the deployment environment (e.g. standalone, portable, desktop).
Defaults to 'local_git' when the file is absent.

The value is sent as an X-Comfy-Deploy-Env header on all requests to
api.comfy.org, allowing the API to differentiate between environment types.

The .comfy_environment file is gitignored so launchers/installers can
write it without affecting the repository.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d939e-6b4d-738b-8d1a-ac7cbf6736a4
2026-04-15 20:13:40 -07:00