openshift / openshift/imagebuilder

`extractHeadlingArgsFromNode` incorrectly uses host `BuiltinArgDefaults`

Open Beginner friendly
#322 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
133
Forks
77
PR merge metrics
No merged PRs in 30d

Description

extractHeadlingArgsFromNode creates headling args using a new temporary builder. However, if the current builder's BuiltinArgDefaults differ from the host's defaults (such as when passing --platform to buildah, which overrides TARGET* args after calling NewBuilder()), the resulting headling args contain the wrong values.

The function should instead copy the current builder's BuiltinArgDefaults into the temporary builder before trying to construct the headling args. The following patch should fix this:

--- a/builder.go
+++ b/builder.go
@@ -6,6 +6,7 @@ import (
        "fmt"
        "io"
        "log"
+       "maps"
        "os"
        "path/filepath"
        "runtime"
@@ -418,6 +419,7 @@ func (b *Builder) extractHeadingArgsFromNode(node *parser.Node) error {

        // Use a separate builder to evaluate the heading args
        tempBuilder := NewBuilder(b.UserArgs)
+       maps.Copy(tempBuilder.BuiltinArgDefaults, b.BuiltinArgDefaults)

        // Built-in ARGs are declared implicitly in the heading and should be resolvable in its scope
        for k, v := range tempBuilder.BuiltinArgDefaults {

The test cases in https://github.com/podman-container-tools/buildah/issues/6964 pass after making this change.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in builder.go at extractHeadingArgsFromNode, where a temporary builder evaluates heading arguments. Check the current and temporary BuiltinArgDefaults, then verify the behavior against the test cases referenced in buildah issue 6964. Done means heading arguments use the current builder's defaults, including values changed by --platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.