Skip to content

fix(agent): render the worker block with indent so long strings keep no newline - #566

Open
agustincelentano wants to merge 1 commit into
mainfrom
fix/agent-worker-values-folding
Open

fix(agent): render the worker block with indent so long strings keep no newline#566
agustincelentano wants to merge 1 commit into
mainfrom
fix/agent-worker-values-folding

Conversation

@agustincelentano

Copy link
Copy Markdown
Collaborator

Problem

nullplatform/agent/templates/nullplatform_agent_values.tmpl.yaml renders the worker block with

worker:
  %{ for line in split("\n", yamlencode(worker)) }
  ${line}
  %{ endfor }

Every iteration emits the line plus the template's own line break, so the rendered block has an empty line between every two lines. That is harmless for short values, but yamlencode folds strings longer than ~80 characters at a space (YAML double-quoted folding), and inside a folded scalar an empty line is a literal newline. A worker patch such as

command = ["sh", "-c", "wget -qO- https://github.com/nullplatform/scopes-networking/archive/refs/tags/v0.1.0.tar.gz | tar -xz --strip-components=1 -C /overrides"]

reaches the chart as wget -qO- https://…/v0.1.0.tar.gz\n| tar …: sh -c runs the wget alone and fails with a syntax error on the next line. Nothing surfaces in plan or apply; the failure shows up in the worker pod. Any worker.patches value with spaces past the fold width is affected (init container commands, args, env values with text).

Hit in production while mounting the scopes-networking overlay into the lambda worker via an init container.

Fix

Render the block with indent(2, yamlencode(worker)), which keeps the encoded lines contiguous. Output for every existing case is identical except for the removed blank lines.

Tests

New run long_worker_patch_strings_survive_rendering decodes the rendered values and asserts the long command comes back intact. It fails on main and passes with the fix; the module suite stays at 25/25.

…no newline

The template re-emitted yamlencode(worker) line by line, leaving an empty
line between every two lines. yamlencode folds strings longer than ~80
characters at a space, and inside a folded double-quoted scalar an empty
line is a literal newline, so a long patch command reached the chart split
in two without any plan or apply error. indent() keeps the block contiguous.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant