Skip to content

Allow to store null variables

Kamil Trzciński requested to merge fix-null-variables into master

What does this MR do?

It seems that I was over-eager assuming that : null variables will be rejected by Runner in json payload, but it proven to not be true and to cause additional problems: https://gitlab.com/gitlab-org/gitlab-ce/issues/54379

This test proves me wrong:

package main

import (
	"encoding/json"
	"fmt"
	"log"
)

type JobVariable struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type JobResponse struct {
	Variables []JobVariable `json:"variables"`
}

func main() {
	var r JobResponse

	body := `{"variables":[{"key":"KEY","value":null}]}`
	err := json.Unmarshal([]byte(body), &r)
	if err != nil {
		log.Fatalln(err)
	}

	saved, err := json.Marshal(&r)
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Print(string(saved))
}

What are the relevant issue numbers?

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/54379

Does this MR meet the acceptance criteria?

Merge request reports