Package: golang-github-gin-gonic-gin
Version: 1.6.3-3
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu impish ubuntu-patch

Dear Maintainer,

Due to changes in net/http and multipart handling in Go 1.17, this package
currently FTBFS with Go 1.17. There is an upstream change that resolves
this failure, so I have pulled it in.

In Ubuntu, the attached patch was applied to achieve the following:

Successfully build the package with Go 1.17.

  * Cherry Pick upstream patch that fixes FTBFS with Go 1.17
    (LP: #1943630)


Thanks for considering the patch.


-- System Information:
Debian Release: bullseye/sid
  APT prefers hirsute-updates
  APT policy: (500, 'hirsute-updates'), (500, 'hirsute-security'), (500, 
'hirsute'), (100, 'hirsute-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.11.0-34-generic (SMP w/32 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru 
golang-github-gin-gonic-gin-1.6.3/debian/patches/0004-fix-test-failure-with-go-1.17.patch
 
golang-github-gin-gonic-gin-1.6.3/debian/patches/0004-fix-test-failure-with-go-1.17.patch
--- 
golang-github-gin-gonic-gin-1.6.3/debian/patches/0004-fix-test-failure-with-go-1.17.patch
   1969-12-31 18:00:00.000000000 -0600
+++ 
golang-github-gin-gonic-gin-1.6.3/debian/patches/0004-fix-test-failure-with-go-1.17.patch
   2021-09-13 13:52:01.000000000 -0500
@@ -0,0 +1,102 @@
+Description: Fix FTBFS with Go 1.17
+ Go 1.17 has multiple changes to mime/multipart and net/http that were causing
+ one of the build-time tests to panic rather than exit cleanly as expected.
+ See https://golang.org/doc/go1.17 for more information
+Origin: upstream, 
https://github.com/gin-gonic/gin/commit/e4c026e2a101de574c480d390da41b91efb9490e
+Bug-Ubuntu: 
https://bugs.launchpad.net/ubuntu/+source/golang-github-gin-gonic-gin/+bug/1943630
+Applied-Upstream: https://github.com/gin-gonic/gin/pull/2856
+Last-Update: 2021-09-13
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- /dev/null
++++ b/context_1.16_test.go
+@@ -0,0 +1,31 @@
++// Copyright 2021 Gin Core Team.  All rights reserved.
++// Use of this source code is governed by a MIT style
++// license that can be found in the LICENSE file.
++
++//go:build !go1.17
++// +build !go1.17
++
++package gin
++
++import (
++      "bytes"
++      "mime/multipart"
++      "net/http"
++      "net/http/httptest"
++      "testing"
++
++      "github.com/stretchr/testify/assert"
++)
++
++func TestContextFormFileFailed16(t *testing.T) {
++      buf := new(bytes.Buffer)
++      mw := multipart.NewWriter(buf)
++      mw.Close()
++      c, _ := CreateTestContext(httptest.NewRecorder())
++      c.Request, _ = http.NewRequest("POST", "/", nil)
++      c.Request.Header.Set("Content-Type", mw.FormDataContentType())
++      c.engine.MaxMultipartMemory = 8 << 20
++      f, err := c.FormFile("file")
++      assert.Error(t, err)
++      assert.Nil(t, f)
++}
+--- /dev/null
++++ b/context_1.17_test.go
+@@ -0,0 +1,33 @@
++// Copyright 2021 Gin Core Team.  All rights reserved.
++// Use of this source code is governed by a MIT style
++// license that can be found in the LICENSE file.
++
++//go:build go1.17
++// +build go1.17
++
++package gin
++
++import (
++      "bytes"
++      "mime/multipart"
++      "net/http"
++      "net/http/httptest"
++      "testing"
++
++      "github.com/stretchr/testify/assert"
++)
++
++func TestContextFormFileFailed17(t *testing.T) {
++      buf := new(bytes.Buffer)
++      mw := multipart.NewWriter(buf)
++      mw.Close()
++      c, _ := CreateTestContext(httptest.NewRecorder())
++      c.Request, _ = http.NewRequest("POST", "/", nil)
++      c.Request.Header.Set("Content-Type", mw.FormDataContentType())
++      c.engine.MaxMultipartMemory = 8 << 20
++      assert.Panics(t, func() {
++              f, err := c.FormFile("file")
++              assert.Error(t, err)
++              assert.Nil(t, f)
++      })
++}
+--- a/context_test.go
++++ b/context_test.go
+@@ -87,19 +87,6 @@
+       assert.NoError(t, c.SaveUploadedFile(f, "test"))
+ }
+ 
+-func TestContextFormFileFailed(t *testing.T) {
+-      buf := new(bytes.Buffer)
+-      mw := multipart.NewWriter(buf)
+-      mw.Close()
+-      c, _ := CreateTestContext(httptest.NewRecorder())
+-      c.Request, _ = http.NewRequest("POST", "/", nil)
+-      c.Request.Header.Set("Content-Type", mw.FormDataContentType())
+-      c.engine.MaxMultipartMemory = 8 << 20
+-      f, err := c.FormFile("file")
+-      assert.Error(t, err)
+-      assert.Nil(t, f)
+-}
+-
+ func TestContextMultipartForm(t *testing.T) {
+       buf := new(bytes.Buffer)
+       mw := multipart.NewWriter(buf)
diff -Nru golang-github-gin-gonic-gin-1.6.3/debian/patches/series 
golang-github-gin-gonic-gin-1.6.3/debian/patches/series
--- golang-github-gin-gonic-gin-1.6.3/debian/patches/series     2021-01-10 
00:15:14.000000000 -0600
+++ golang-github-gin-gonic-gin-1.6.3/debian/patches/series     2021-09-13 
13:50:26.000000000 -0500
@@ -1,3 +1,4 @@
 0001-adjust-test-parameters.patch
 0002-binding-avoid-2038-problem-on-32-bit-architectures.patch
 0003-avoid-failures-on-flaky-test.patch
+0004-fix-test-failure-with-go-1.17.patch

Reply via email to