API publish POST broken with aptly v1.5.0 with 500 internal server errror
With the upgrade from aptly_1.4.0+176+g4c04e774_amd64.deb (downloaded from PR https://github.com/aptly-dev/aptly/pull/1050) to the v1.5.0 release the api/publish endpoint broke
using the aptly publish command works without an issue
Detailed Description
Geting the followin error:
Aug 08 14:11:12 aptly[601]: [GIN] 2022/08/08 - 14:11:12 | 200 | 73.228374ms | 192.168.1.70 | GET "/api/snapshots?sort=time"
Aug 08 14:11:12 aptly[601]: [GIN] 2022/08/08 - 14:11:12 | 200 | 163.794538ms | 192.168.1.70 | GET "/api/publish"
Aug 08 14:11:12 aptly[601]: 2022/08/08 14:11:12 Executing task synchronously
Aug 08 14:11:12 aptly[601]: 2022/08/08 14:11:12 [Recovery] 2022/08/08 - 14:11:12 panic recovered:
Aug 08 14:11:12 aptly[601]: POST /api/publish/:. HTTP/1.0
Aug 08 14:11:12 aptly[601]: Host: burner
Aug 08 14:11:12 aptly[601]: Connection: close
Aug 08 14:11:12 aptly[601]: Accept: application/json
Aug 08 14:11:12 aptly[601]: Accept-Encoding: gzip, deflate
Aug 08 14:11:12 aptly[601]: Connection: close
Aug 08 14:11:12 aptly[601]: Content-Length: 292
Aug 08 14:11:12 aptly[601]: Content-Type: application/json
Aug 08 14:11:12 aptly[601]: User-Agent: python-requests/2.25.1
Aug 08 14:11:12 aptly[601]: X-Forwarded-For: 192.168.1.70
Aug 08 14:11:12 aptly[601]: X-Real-Ip: 192.168.1.70
Aug 08 14:11:12 aptly[601]:
Aug 08 14:11:12 aptly[601]: runtime error: invalid memory address or nil pointer dereference
Aug 08 14:11:12 aptly[601]: /opt/hostedtoolcache/go/1.17.11/x64/src/runtime/panic.go:221 (0x44d906)
Aug 08 14:11:12 aptly[601]: /opt/hostedtoolcache/go/1.17.11/x64/src/runtime/signal_unix.go:735 (0x44d8d6)
Aug 08 14:11:12 aptly[601]: /home/runner/work/aptly/aptly/api/publish.go:215 (0xd48f65)
Aug 08 14:11:12 aptly[601]: /home/runner/work/aptly/aptly/api/api.go:151 (0xd3fac2)
Aug 08 14:11:12 aptly[601]: /home/runner/work/aptly/aptly/api/publish.go:188 (0xd481e4)
Aug 08 14:11:12 aptly[601]: /home/runner/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168 (0xd54dde)
Aug 08 14:11:12 aptly[601]: /home/runner/work/aptly/aptly/api/router.go:63 (0xd54da8)
Aug 08 14:11:12 aptly[601]: /home/runner/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168 (0xa0287b)
Aug 08 14:11:12 aptly[601]: /home/runner/go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:173 (0xa02866)
Aug 08 14:11:12 aptly[601]: /home/runner/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168 (0xa03b01)
Aug 08 14:11:12 aptly[601]: /home/runner/go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:99 (0xa03aec)
Aug 08 14:11:12 aptly[601]: /home/runner/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168 (0xa02d66)
Aug 08 14:11:12 aptly[601]: /home/runner/go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:241 (0xa02d49)
Aug 08 14:11:12 aptly[601]: /home/runner/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168 (0xa02150)
Aug 08 14:11:12 aptly[601]: /home/runner/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:555 (0xa01db8)
Aug 08 14:11:12 aptly[601]: /home/runner/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:511 (0xa018f1)
Aug 08 14:11:12 aptly[601]: /opt/hostedtoolcache/go/1.17.11/x64/src/net/http/server.go:2879 (0x6fbf9a)
Aug 08 14:11:12 aptly[601]: /opt/hostedtoolcache/go/1.17.11/x64/src/net/http/server.go:1930 (0x6f7647)
Aug 08 14:11:12 aptly[601]: /opt/hostedtoolcache/go/1.17.11/x64/src/runtime/asm_amd64.s:1581 (0x4695a0)
Aug 08 14:11:12 aptly[601]:
Aug 08 14:11:12 aptly[601]: [GIN] 2022/08/08 - 14:11:12 | 500 | 104.61081ms | 192.168.1.70 | POST "/api/publish/:."
Trigger the internal server error by issuing a POST command to the api/publish/:. endpoint
curl -X POST -H 'Content-Type: application/json' --data '{"Storage": "", "SourceKind": "snapshot", "Distribution": "cmake", "Sources": [{"Component": "external", "Name": "cmake_trusty-220411074201"}], "ForceOverwrite": true, "SkipContents": true, "AcquireByHash": false}' http://localhost:8080/api/publish/:.
or with python
import requests
url="http://localhost:8080/api/publish/:."
data={"Storage": "", "SourceKind": "snapshot", "Distribution": "cmake", "Sources": [{"Component": "external", "Name": "cmake_trusty-220411074201"}], "ForceOverwrite": True, "SkipContents": True, "AcquireByHash": False}
r = requests.post(url, json=data)
print(r.text)
Context
Can't use the API publish entpoint anymore after the upgrade, need to downgrade
Possible Implementation
One of the following commits may be the culprit https://github.com/aptly-dev/aptly/compare/c1e577c1ac4ec5c9d4f41c86458f714c370474c7...v1.5.0
Your Environment
Ubuntu 20.04 amd64
Tried the nightly http://repo.aptly.info/pool/main/a/aptly/aptly_1.5.0+11+g42cfee2c_amd64.deb and it now works! Thanks @randombenj