fix: resolve container: ${{ matrix.container }} map indirection instead of stringifying to "Object"#6112
Open
elijahr wants to merge 5 commits into
Open
Conversation
Extract the scalar-vs-mapping decode switch from Job.Container() into an
exported model.DecodeContainerNode(*yaml.Node) *ContainerSpec so the runner's
per-RunContext container resolver can decode an evaluated node with
byte-identical semantics. Job.Container() now delegates to it.
Semantics are preserved exactly: empty scalar -> &ContainerSpec{Image:""}
(not nil); decode error -> OnDecodeNodeError (fatal by default) -> nil;
nil/zero node -> nil (host execution).
A job-level `container: ${{ matrix.container }}` where each matrix cell
supplies a container MAP was stringified to the literal "Object" (pulling
docker.io/library/Object), because Job.Container() decoded the unevaluated
scalar and Interpolate's forceFormat=true coerced the map to "Object".
Add a per-RunContext resolveJobContainer(ctx) that deep-copies the shared
RawContainer yaml.Node, evaluates the COPY with the type-preserving
EvaluateYamlNode (forceFormat=false), and decodes via the shared
model.DecodeContainerNode helper. The result is memoized on a new
resolvedJobContainer field. All five .Container() consumers (containerImage,
options, GetBindsAndMounts, handleCredentials, mergeEnv) route through the
resolver; GetBindsAndMounts gains a ctx parameter threaded from its three
production callers.
The shared *Job is NEVER mutated: cells run in parallel and share one *Job
pointer, so in-place evaluation would leak across cells and race. Deep-copy +
per-RunContext memo make resolution race-free by construction. When ExprEval
is nil (a consumer reached before startJob sets it, or the bare-RC unit
harness), the resolver falls back to a pure decode of the un-evaluated node,
exactly reproducing the prior Job.Container() behavior.
Tests: TestResolveJobContainer covers the distinct-image leak guard,
sibling-field preservation, undefined-matrix host fallback (pinned to the
observed empty-image-no-error branch), plain-string back-compat, nested-expr
recursion, and nil-ExprEval pure-decode. TestResolveJobContainer_ParallelCells
NoLeak proves race-freedom under -race. A Docker-guarded matrix-container
integration fixture is added to the TestRunEvent table.
Addresses review feedback: defensive nil checks for rc.Run/job and nil-safe deepCopyYamlNode.
…terpolation Addresses review feedback: memoize the resolved container only when ExprEval is set (avoids caching an un-evaluated spec), and remove the redundant, nil-unsafe Interpolate calls in containerImage/options since resolveJobContainer already fully evaluates the node.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
container: ${{ matrix.container }}at the job level, where each matrix entry supplies acontainer:map, was stringified to the literal"Object"— act tried to pulllibrary/Objectinstead of the map's image. The container field was decoded before the matrix expression was evaluated, so the map structure was lost.This resolves the container per job-run: it deep-copies the raw
container:node, evaluates the copy with act's type-preserving evaluator (the same oneruns-onuses), then decodes it — so${{ matrix.container }}becomes the actual map with itsimageand sibling fields (env,options,ports, etc.). Plain-string containers, embedded expressions, and jobs with no container behave exactly as before. The deep copy is deliberate: the job is shared across matrix cells that run in parallel, so mutating it in place would leak the container between cells and race.Added regression tests in
run_context_test.go, including a parallel-cells-racetest that guards cross-cell leakage.