-
Notifications
You must be signed in to change notification settings - Fork 131
Add Comfy-Usage-Source header to ComfyUI and cloud API requests #468
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,7 +175,7 @@ def test_queue_embeds_api_key_in_extra_data(self, workflow): | |
| ex.queue() | ||
| req = mock_open.call_args[0][0] | ||
| body = json.loads(req.data) | ||
| assert body["extra_data"] == {"api_key_comfy_org": "sk-secret"} | ||
| assert body["extra_data"] == {"comfy_usage_source": "comfy-cli", "api_key_comfy_org": "sk-secret"} | ||
|
|
||
| def test_queue_does_not_send_x_api_key_header(self, workflow): | ||
| ex = self._make_exec(workflow, api_key="sk-secret") | ||
|
|
@@ -185,15 +185,26 @@ def test_queue_does_not_send_x_api_key_header(self, workflow): | |
| req = mock_open.call_args[0][0] | ||
| assert req.get_header("X-api-key") is None | ||
|
|
||
| def test_queue_omits_extra_data_when_no_api_key(self, workflow): | ||
| def test_queue_omits_api_key_when_not_set(self, workflow): | ||
| ex = self._make_exec(workflow) | ||
| with patch("comfy_cli.command.run.request.urlopen") as mock_open: | ||
| mock_open.return_value.read.return_value = json.dumps({"prompt_id": "abc"}).encode() | ||
| ex.queue() | ||
| req = mock_open.call_args[0][0] | ||
| body = json.loads(req.data) | ||
| assert "extra_data" not in body | ||
| assert body == {"prompt": workflow, "client_id": ex.client_id} | ||
| assert body == { | ||
| "prompt": workflow, | ||
| "client_id": ex.client_id, | ||
| "extra_data": {"comfy_usage_source": "comfy-cli"}, | ||
| } | ||
|
|
||
| def test_queue_sends_usage_source_header(self, workflow): | ||
| ex = self._make_exec(workflow) | ||
| with patch("comfy_cli.command.run.request.urlopen") as mock_open: | ||
| mock_open.return_value.read.return_value = json.dumps({"prompt_id": "abc"}).encode() | ||
| ex.queue() | ||
| req = mock_open.call_args[0][0] | ||
| assert req.get_header("Comfy-usage-source") == "comfy-cli" | ||
|
Comment on lines
+201
to
+207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify that urllib.request.Request.get_header() is case-insensitive
python -c "
import urllib.request
req = urllib.request.Request('http://example.com')
req.add_header('Comfy-Usage-Source', 'test-value')
# Test various casings
print('Exact match:', req.get_header('Comfy-Usage-Source'))
print('Lowercase u:', req.get_header('Comfy-usage-source'))
print('All lowercase:', req.get_header('comfy-usage-source'))
print('All uppercase:', req.get_header('COMFY-USAGE-SOURCE'))
# Check if all variants return the same value
variants = [
req.get_header('Comfy-Usage-Source'),
req.get_header('Comfy-usage-source'),
req.get_header('comfy-usage-source'),
req.get_header('COMFY-USAGE-SOURCE')
]
if all(v == 'test-value' for v in variants):
print('✓ get_header() is case-insensitive')
else:
print('✗ get_header() is case-sensitive - test may fail')
"Repository: Comfy-Org/comfy-cli Length of output: 194 Align
🧰 Tools🪛 Pylint (4.0.5)[convention] 201-201: Missing function or method docstring (C0116) [warning] 201-201: Redefining name 'workflow' from outer scope (line 21) (W0621) 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| class TestWatchExecution: | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.