mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-09 04:06:42 +00:00
fix(env): hand a swarm env value to the container verbatim
_passthrough_swarm quoted and escaped any value containing whitespace,
which contradicts the contract stated at the top of the same module:
docker stack deploy does not strip outer quotes, so the value reaches the
container with them.
Ansible's to_json emits the default ", " separators, so AGENT_PLATFORMS
always carried spaces and arrived as "{\"hermes\": ...}". json.loads then
returned a str rather than a mapping, and sorted(PLATFORMS) in the broker
iterated its characters: the broker advertised one model per character and
never hermes or openclaw, which is why Open WebUI's model list held neither
and the agent-broker specs failed before reaching a completion. The same
encoding mangled AGENT_CONSTRAINT, whose placement expression would have
failed once an agent was reachable.
The branch existed for the opposite consumer: test.env is sourced by bash,
where KEY=one two leaves the variable unset under set -u. Quoting is the
wrong instrument for that, because one filter cannot serve both contracts
keyed on DEPLOYMENT_MODE alone. Both values that join on a space now join
on a comma and their consumers split on one, so no rendered env value needs
quoting to survive the shell.
Two unit tests asserted the quoting while a sibling in the same class
asserted that swarm does not escape a double quote; the pair could not both
hold. They are replaced by one test that renders real JSON and checks the
container receives a mapping. The lint that flags a space-joined value no
longer accepts dotenv_quote as the remedy, since in swarm it no longer
quotes, and its message names the comma instead.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
594d242349
commit
8e535f2ccf
8 files changed
+35
-22
No files matched your search
@@ -94,14 +94,14 @@ class TestDotenvQuoteModeAware(unittest.TestCase):
|
||||
def test_swarm_non_string_is_stringified(self):
|
||||
self.assertEqual(self._render(42, mode="swarm"), "42")
|
||||
|
||||
def test_swarm_quotes_value_with_interior_whitespace(self):
|
||||
def test_swarm_passes_a_value_with_spaces_through_unchanged(self):
|
||||
self.assertEqual(
|
||||
self._render("My Org Helpdesk", mode="swarm"), '"My Org Helpdesk"'
|
||||
self._render('{"hermes": {"group": "/x"}}', mode="swarm"),
|
||||
'{"hermes": {"group": "/x"}}',
|
||||
"swarm delivers the value verbatim, so quoting it makes the "
|
||||
"container read the quotes as part of the JSON and parse a string",
|
||||
)
|
||||
|
||||
def test_swarm_whitespace_value_escapes_quotes_not_dollars(self):
|
||||
self.assertEqual(self._render('a "b" $c', mode="swarm"), '"a \\"b\\" $c"')
|
||||
|
||||
def test_compose_mode_quotes_like_default(self):
|
||||
self.assertEqual(self._render("abc", mode="compose"), '"abc"')
|
||||
self.assertEqual(self._render("$ecret", mode="compose"), '"$$ecret"')
|
||||
|
||||
Reference in new issue
Block a user