release-cli create panics when an --assets-link array contains null
### Summary
`release-cli create` ends in a recovered nil pointer panic when the JSON array given to `--assets-link` contains `null`, instead of an error that names the bad input.
### Steps to reproduce
On `master` (07d5e21c6610f781b65d7196c5d0e86e73bcc6be) with Go 1.24.1, the version `.tool-versions` pins:
1. `go build -o release-cli ./cmd/release-cli`
2. `./release-cli --server-url http://127.0.0.1:9 --job-token x --project-id 1 create --tag-name v1.0.0 --assets-link '[{"name":"a","url":"https://example.com/a"}, null]'`
`[null]` alone does the same. No server is needed: it fails while the flags are parsed, before any request.
### Example Project
None needed, the command above is enough.
### What is the current *bug* behavior?
```
level=fatal msg="recovered from panic: runtime error: invalid memory address or nil pointer dereference" cli=release-cli version=
```
### What is the expected *correct* behavior?
An `invalid array of assets: "<input>" ...` error, as the other malformed arrays get.
### Relevant logs and/or screenshots
One of the patch's two test cases, run without its fix:
```
--- FAIL: TestAssetMarshaller/array_of_assets_with_a_null_entry (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
gitlab.com/gitlab-org/release-cli/internal/gitlab.ensureUsingDirectAssetPath(...)
/src/internal/gitlab/asset_marshaller.go:86
gitlab.com/gitlab-org/release-cli/internal/gitlab.processMultipleAssets({0x7f087d, 0x46}, 0xc00006b040)
/src/internal/gitlab/asset_marshaller.go:75 +0x121
```
### Output of checks
Not specific to GitLab.com: it happens in release-cli itself, before any request is sent.
### Possible fixes
`processMultipleAssets` decodes the array into `[]*Link`, so `null` becomes a nil `*Link`, and `ensureUsingDirectAssetPath` reads `link.Filepath` from it ([asset_marshaller.go#L74-86](https://gitlab.com/gitlab-org/release-cli/-/blob/07d5e21c6610f781b65d7196c5d0e86e73bcc6be/internal/gitlab/asset_marshaller.go#L74-86)). The panic is recovered in [main.go#L29-33](https://gitlab.com/gitlab-org/release-cli/-/blob/07d5e21c6610f781b65d7196c5d0e86e73bcc6be/cmd/release-cli/main.go#L29-33).
I know release-cli is deprecated in favor of glab and does not take merge requests, so the fix is below as a patch for `git am`, for whoever can apply it. It returns an `invalid array of assets` error for a nil entry before the alias check, and adds two cases to `TestAssetMarshaller`. Both cases panic on `master` and pass with the patch, and `go test ./...` passes with it. glab has refused a null entry in `--assets-links` since v1.125.0 (gitlab-org/cli!4211).
<details><summary>Patch: Return an error for a null entry in an asset link array</summary>
```diff
From 3a8dcbaedea9891e9626fe6ea45adb9770b77756 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20M=2E=20Requena=20Plens?= <mail@jmrp.io>
Date: Fri, 30 Oct 2026 15:18:14 +0100
Subject: [PATCH] Return an error for a null entry in an asset link array
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
processMultipleAssets decodes an --assets-link array into []*Link. A
JSON null element decodes to a nil *Link, which was passed straight to
ensureUsingDirectAssetPath. That function reads link.Filepath, so an
input such as '[null]' ended in a recovered nil pointer panic instead
of an error naming the bad input.
Reject a nil entry with an "invalid array of assets" error, the same
prefix the other array errors use, before the alias check runs. A null
link is not skipped silently: it can only come from a mistake in the
JSON the user wrote, and the release must not be created with fewer
assets than requested.
Signed-off-by: José M. Requena Plens <mail@jmrp.io>
---
internal/gitlab/asset_marshaller.go | 4 ++++
internal/gitlab/asset_marshaller_test.go | 10 ++++++++++
2 files changed, 14 insertions(+)
diff --git a/internal/gitlab/asset_marshaller.go b/internal/gitlab/asset_marshaller.go
index 3a8c28c..f4818c2 100644
--- a/internal/gitlab/asset_marshaller.go
+++ b/internal/gitlab/asset_marshaller.go
@@ -72,6 +72,10 @@ func processMultipleAssets(entry string, assets *Assets) error {
}
for _, link := range links {
+ if link == nil {
+ return fmt.Errorf("invalid array of assets: %q contains a null asset link", entry)
+ }
+
if err := ensureUsingDirectAssetPath(link); err != nil {
return fmt.Errorf("invalid array of assets: %q %w", entry, err)
}
diff --git a/internal/gitlab/asset_marshaller_test.go b/internal/gitlab/asset_marshaller_test.go
index 4cb64ad..eef902f 100644
--- a/internal/gitlab/asset_marshaller_test.go
+++ b/internal/gitlab/asset_marshaller_test.go
@@ -100,6 +100,16 @@ func TestAssetMarshaller(t *testing.T) {
expectedErrorMessage: `invalid array of assets: "[\"fake_asset\", \"another_fake_asset\"]"`,
expectedOriginalError: "json: cannot unmarshal string into Go value of type gitlab.Link",
},
+ "array_of_assets_with_a_null_entry": {
+ assetLink: []string{`[{"name":"asset1", "url":"https://gitlab.com", "filepath":"/a"}, null]`},
+ expectedAssetLength: 0,
+ expectedErrorMessage: `invalid array of assets: "[{\"name\":\"asset1\", \"url\":\"https://gitlab.com\", \"filepath\":\"/a\"}, null]" contains a null asset link`,
+ },
+ "array_of_only_null": {
+ assetLink: []string{`[null]`},
+ expectedAssetLength: 0,
+ expectedErrorMessage: `invalid array of assets: "[null]" contains a null asset link`,
+ },
"single_and_array_of_assets": {
assetLink: []string{`{"name":"asset1", "url":"https://gitlab.com"}`, `[{"name":"asset2", "url":"https://gitlab.com/gitlab-org"}, {"name":"asset3", "url":"https://gitlab.com/gitlab-org/gitlab"}]`, `{"name":"asset4", "url":"https://gitlab.com/gitlab-org/release-cli"}`},
expectedAssetLength: 4,
base-commit: 07d5e21c6610f781b65d7196c5d0e86e73bcc6be
```
</details>
Found while working on [gitlab-mcp-server](https://github.com/jmrplens/gitlab-mcp-server).
issue
GitLab AI Context
Project: gitlab-org/release-cli
Instance: https://gitlab.com
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://gitlab.com/gitlab-org/release-cli/-/raw/master/CONTRIBUTING.md — contribution guidelines
- https://gitlab.com/gitlab-org/release-cli/-/raw/master/README.md — project overview and setup
Repository: https://gitlab.com/gitlab-org/release-cli
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD