Skip to content

extractHeadlingArgsFromNode incorrectly uses host BuiltinArgDefaults #322

Open

Description

@isaac-sec

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 podman-container-tools/buildah#6964 pass after making this change.

Activity

  1. openshift-ci commented on Oct 15, 2026

    @openshift-ci
    Contributor

    Issues go stale after 90d of inactivity.

    Mark the issue as fresh by commenting /remove-lifecycle stale.
    Stale issues rot after an additional 30d of inactivity and eventually close.
    Exclude this issue from closing by commenting /lifecycle frozen.

    If this issue is safe to close now please do so with /close.

    /lifecycle stale

  2. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions