Skip to content

go-archive tests failing on go1.26.5 #9635

Closed

Description

@taylorsilva

Summary

Latest go version 1.26.5 broke some tests in go-archive. Here's the test output:

[1783524239] Tarfs Suite - 12/12 specs - 9 procs ••
------------------------------
• [FAILED] [0.002 seconds]
ExtractEntry hard links [It] turns absolute paths into relative paths inside dest
/Users/taylor/workspace/concourse/concourse/go-archive/tarfs/extract_test.go:178

  Timeline >>
  STEP: creating the target of the hard link @ 07/08/26 11:23:59.647
  [FAILED] in [It] - /Users/taylor/workspace/concourse/concourse/go-archive/tarfs/extract_test.go:189 @ 07/08/26 11:23:59.648
  << Timeline

  [FAILED] Unexpected error:
      <*fs.PathError | 0x7a1c1ee0e600>:
      mkdirat absolute/path/: no such file or directory
      {
          Op: "mkdirat",
          Path: "absolute/path/",
          Err: <syscall.Errno>0x2,
      }
  occurred
  In [It] at: /Users/taylor/workspace/concourse/concourse/go-archive/tarfs/extract_test.go:189 @ 07/08/26 11:23:59.648
------------------------------
•••••••••

Summarizing 1 Failure:
  [FAIL] ExtractEntry hard links [It] turns absolute paths into relative paths inside dest
  /Users/taylor/workspace/concourse/concourse/go-archive/tarfs/extract_test.go:189

Ran 12 of 12 Specs in 0.022 seconds
FAIL! -- 11 Passed | 1 Failed | 0 Pending | 0 Skipped

[1783524239] Tgzfs Suite - 8/8 specs - 9 procs •••••••• SUCCESS! 20.135ms
[1783524239] Zipfs Suite - 2/2 specs - 9 procs
------------------------------
• [FAILED] [0.002 seconds]
Extract [JustBeforeEach] when 'unzip' is not in the PATH extracts the ZIP's files, generating directories, and honoring file permissions and symlinks
  [JustBeforeEach] /Users/taylor/workspace/concourse/concourse/go-archive/zipfs/extract_test.go:68
  [It] /Users/taylor/workspace/concourse/concourse/go-archive/zipfs/extract_test.go:138

  [FAILED] Unexpected error:
      <*fs.PathError | 0x5303aae8c2d0>:
      mkdirat ./empty-dir/: no such file or directory
      {
          Op: "mkdirat",
          Path: "./empty-dir/",
          Err: <syscall.Errno>0x2,
      }
  occurred
  In [JustBeforeEach] at: /Users/taylor/workspace/concourse/concourse/go-archive/zipfs/extract_test.go:70 @ 07/08/26 11:24:00.315
------------------------------
•

Summarizing 1 Failure:
  [FAIL] Extract [JustBeforeEach] when 'unzip' is not in the PATH extracts the ZIP's files, generating directories, and honoring file permissions and symlinks
  /Users/taylor/workspace/concourse/concourse/go-archive/zipfs/extract_test.go:70

Ran 2 of 2 Specs in 0.009 seconds
FAIL! -- 1 Passed | 1 Failed | 0 Pending | 0 Skipped


Ginkgo ran 3 suites in 1.281022167s

There were failures detected in the following suites:
  tarfs ./go-archive/tarfs
  zipfs ./go-archive/zipfs

Test Suite Failed

Looking at the Go release milestone: https://github.com/golang/go/milestone/439?closed=1
This issue seems like a possible culprit: golang/go#79027

Activity

  1. taylorsilva commented on Jul 8, 2026

    @taylorsilva
    MemberAuthor

    I think this is a bug in Go. Seems like root.MkdirAll() func fails to create the path if it ends in a /. It didn't previously do that.

    Reproducible:

    package main
    
    import (
    	"log"
    	"os"
    )
    
    func main() {
    	r, err := os.OpenRoot(".")
    	if err != nil {
    		log.Fatalf("OpenRoot: %s", err.Error())
    	}
    	err = r.MkdirAll("some/path/", 0755)
    	if err != nil {
    		log.Fatalf("MkdirAll: %s", err.Error())
    	}
    }

    Changing some/path/ to some/path works.

  2. taylorsilva commented on Jul 8, 2026

    @taylorsilva
    MemberAuthor

    Reported in golang/go#80308

  3. taylorsilva commented on Jul 8, 2026

    @taylorsilva
    MemberAuthor

    The above I found in the tarfs package. The zipfs package is also failing with a different error, also from os.Root. Looking into that now.

  4. taylorsilva commented on Jul 8, 2026

    @taylorsilva
    MemberAuthor

    So zipfs package was also failing with:

      [FAILED] Unexpected error:
          <*fs.PathError | 0x3ab97cf0e6c0>:
          mkdirat ./empty-dir/: no such file or directory
          {
              Op: "mkdirat",
              Path: "./empty-dir/",
              Err: <syscall.Errno>0x2,
          }
      occurred
      In [JustBeforeEach] at: /Users/taylor/workspace/concourse/concourse/go-archive/zipfs/extract_test.go:70
    

    Which is because these paths end in /, so same issue as above in tarfs:

    {
    Name: "./empty-dir/",
    Dir: true,
    },
    {
    Name: "./nonempty-dir/",
    Dir: true,
    },

    Removing the / at the end of the paths results in a new error:

      [FAILED] Unexpected error:
          <*fmt.wrapError | 0x3d533cbaba80>:
          TAYDEV-3: mkdirat nonempty-dir: file exists
          {
              msg: "TAYDEV-3: mkdirat nonempty-dir: file exists",
              err: <*fs.PathError | 0x3d533cd479e0>{
                  Op: "mkdirat",
                  Path: "nonempty-dir",
                  Err: <syscall.Errno>0x11,
              },
          }
      occurred
      In [JustBeforeEach] at: /Users/taylor/workspace/concourse/concourse/go-archive/zipfs/extract_test.go:70
    

    Not sure why that happens and can't reproduce with the main.go I previously made.

    For now I'm re-building our images with go1.26.4 just to unblock us. Will keep digging into this and figure out a code workaround.

  5. taylorsilva commented on Jul 8, 2026

    @taylorsilva
    MemberAuthor

    So the zipfs error happens because it seems that zip files only know if a file is a directory if it has a trailing /, so my workaround of removing the / doesn't work for zip files.

    Figured this out by looking at the error the unzip binary returns in another test in the same suite:

    checkdir error:  /private/var/folders/z_/9m650jjx5r7c5226dltkzt6w0000gn/T/extracted551756948/nonempty-dir exists but is not directory
                       unable to process ./nonempty-dir/file-in-dir.
    

    Without the trailing / it creates a file nonempty-dir instead of a directory.

  6. taylorsilva commented on Jul 8, 2026

    @taylorsilva
    MemberAuthor

    I think our only solutions here are either:

    1. Wait for the next go patch which will hopefully fix this, or
    2. Go back to using the original os package functions which doesn't have this issue with MkdirAll
  7. added this to the v8.3.0 milestone on Jul 8, 2026
  8. Kump3r commented on Jul 9, 2026

    @Kump3r
    Contributor

    @taylorsilva imho we should maybe try with option one, but if the golang people take their sweet time, we can always go for option 2 at that point. My main concern in going directly for point 2 would be stuff like (

    // Absolute symlinks are left as-is because in containerized
    // environments absolute paths won't escape the container. For
    // non-containerized environments, sorry, can't help ya! We do use
    // os.Root, so if someone tries to do an extraction attack by:
    // 1) Creating a symlink that points at an absolute path
    // 2) Create a file that would follow that symlink, writing outside
    // the extraction path
    // os.Root won't allow that.
    // For symlinks pointing to relative paths, we detect if they try to
    // point to a path outside of the destination path and return a BreakoutErr
    ). We would need to implement the path-escape checks in the software and not rely on the built-in. Maybe you would have better judgement for how fast the upstream responds, but as far as I understand and given my limited context I would personally go for option 1.

  9. taylorsilva commented on Jul 9, 2026

    @taylorsilva
    MemberAuthor

    Just looked at their release history and it looks like patch releases are made at the beginning of each month. So we can't expect a fix until August now.

    I guess a third option could be to trim the trailing / from the filepath. I think I'll just do that and move on from this.

  10. taylorsilva commented on Jul 10, 2026

    @taylorsilva
    MemberAuthor

    The upstream issue in Go has been closed and backported to go1.25 and go1.26. We can remove our workaround when the next patch release for go1.26 comes out.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions