Sent hidden fields make setting short variables fail
Hi,
It is not possible to set group variables. Setting repo variables work though.
Gitlab paying customer here
⇶ GLAB_DEBUG_HTTP=true glab variable set foo value -g "train/platform/switchyard"
REQUEST:
POST /api/v4/groups/train%2Fplatform%2Fswitchyard/variables HTTP/1.1
Host: gitlab.cust.ch
User-Agent: glab/v1.78.3 (linux, amd64)
Content-Length: 167
Accept: application/json
Content-Type: application/json
Private-Token: [REDACTED]
Accept-Encoding: gzip
{"key":"foo","value":"value","description":"","environment_scope":"*","masked":false,"masked_and_hidden":false,"protected":false,"raw":false,"variable_type":"env_var"}
RESPONSE:
HTTP/1.1 400 Bad Request
Content-Length: 36
Cache-Control: no-cache
Connection: keep-alive
Content-Type: application/json
Date: Mon, 24 Nov 2025 16:34:29 GMT
Nel: {"max_age": 0}
Server: nginx
Strict-Transport-Security: max-age=63072000
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Gitlab-Meta: {"correlation_id":"01KAVBEYK6Q62A8CF8174V6FY3","version":"1"}
X-Request-Id: 01KAVBEYK6Q62A8CF8174V6FY3
X-Runtime: 0.068441
{"message":{"value":["is invalid"]}}
When trying with the glab api:
Without setting the masked_and_hidden field:
⇶ GLAB_DEBUG_HTTP=true glab api --method POST "groups/train%2Fplatform%2Fswitchyard/variables" --field "key=FOO_FVD" --field "value=var" --field 'description="foo bar"' --field 'environment_scope=*' --field 'masked=false'
REQUEST:
POST /api/v4/groups/train%2Fplatform%2Fswitchyard/variables HTTP/1.1
Host: gitlab.cust.ch
User-Agent: glab/v1.78.3 (linux, amd64)
Content-Length: 98
Content-Type: application/json; charset=utf-8
Private-Token: [REDACTED]
Accept-Encoding: gzip
{"description":"\"foo bar\"","environment_scope":"*","key":"FOO_FVD","masked":false,"value":"var"}
RESPONSE:
HTTP/1.1 201 Created
Content-Length: 169
Cache-Control: max-age=0, private, must-revalidate
Connection: keep-alive
Content-Type: application/json
Date: Mon, 24 Nov 2025 16:35:08 GMT
Etag: W/"ee35dd92640fe6bac966f8b529f7a08f"
Nel: {"max_age": 0}
Referrer-Policy: strict-origin-when-cross-origin
Server: nginx
Strict-Transport-Security: max-age=63072000
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Gitlab-Meta: {"correlation_id":"01KAVBG5BDPP7TH0AV9YRMT4E9","version":"1"}
X-Request-Id: 01KAVBG5BDPP7TH0AV9YRMT4E9
X-Runtime: 0.136841
{"variable_type":"env_var","key":"FOO_FVD","value":"var","hidden":false,"protected":false,"masked":false,"raw":false,"environment_scope":"*","description":"\"foo bar\""}
{
"variable_type": "env_var",
"key": "FOO_FVD",
"value": "var",
"hidden": false,
"protected": false,
"masked": false,
"raw": false,
"environment_scope": "*",
"description": "\"foo bar\""
}
And with setting the masked_and_hidden field:
⇶ GLAB_DEBUG_HTTP=true glab api --method POST "groups/train%2Fplatform%2Fswitchyard/variables" --field "key=FOO_FVD" --field "value=var" --field 'description="foo bar"' --field 'environment_scope=*' --field 'masked=false' --field='masked_and_hidden=false'
REQUEST:
POST /api/v4/groups/train%2Fplatform%2Fswitchyard/variables HTTP/1.1
Host: gitlab.cust.ch
User-Agent: glab/v1.78.3 (linux, amd64)
Content-Length: 124
Content-Type: application/json; charset=utf-8
Private-Token: [REDACTED]
Accept-Encoding: gzip
{"description":"\"foo bar\"","environment_scope":"*","key":"FOO_FVD","masked":false,"masked_and_hidden":false,"value":"var"}
RESPONSE:
HTTP/1.1 400 Bad Request
Content-Length: 36
Cache-Control: no-cache
Connection: keep-alive
Content-Type: application/json
Date: Mon, 24 Nov 2025 16:35:03 GMT
Nel: {"max_age": 0}
Server: nginx
Strict-Transport-Security: max-age=63072000
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Gitlab-Meta: {"correlation_id":"01KAVBG0A3TWXJV3276HSWGS9C","version":"1"}
X-Request-Id: 01KAVBG0A3TWXJV3276HSWGS9C
X-Runtime: 0.058127
{"message":{"value":["is invalid"]}}
{
"message": {
"value": ["is invalid"]
}
}
glab: map[message:map[value:[is invalid]]]+
Versions
glab 1.78.3 (b234b22a)
GitLab version v18.2.1-ee