Skip to content

HTTP 500 triggering pipeline API with variables

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Triggering a pipeline with variables defined via the projects/:id/pipeline API route hangs for 11 seconds and then spits out an HTTP 500.

For easy reproduction, I've created a project, user, associated access token, and crappy pipeline that just prints a variable, so you can just paste these commands directly to trigger the demo pipeline.

The pipeline can be invoked just fine without variables:

curl -X POST --header "Private-Token: Fp_crazaAzBpaY-CCps7" -F ref=master "https://gitlab.com/api/v4/projects/BuggyMcBugface%2FTriggerFail/pipeline"

Any attempt to add the variables field causes the API call to hang and then returning {"message":"500 Internal Server Error"}. Either I'm doing something profoundly silly, or this is quite broken :D

All of these fail like that:

# Empty-string variables?
curl -X POST --header "Private-Token: Fp_crazaAzBpaY-CCps7" -F ref=master -F "variables=" "https://gitlab.com/api/v4/projects/BuggyMcBugface%2FTriggerFail/pipeline"

# Empty-array variables?
curl -X POST --header "Private-Token: Fp_crazaAzBpaY-CCps7" -F ref=master -F "variables=[]" "https://gitlab.com/api/v4/projects/BuggyMcBugface%2FTriggerFail/pipeline"

# Array-of-weird-objects?
curl -X POST --header "Private-Token: Fp_crazaAzBpaY-CCps7" -F ref=master -F "variables=[{'key'=>'MY_VARIABLE', 'value'=>'FOO'}]" "https://gitlab.com/api/v4/projects/BuggyMcBugface%2FTriggerFail/pipeline"

# Array-of-weird-objects, minus quotes??
curl -X POST --header "Private-Token: Fp_crazaAzBpaY-CCps7" -F ref=master -F "variables=[{'key'=>'MY_VARIABLE', 'value'=>'FOO'}]" "https://gitlab.com/api/v4/projects/BuggyMcBugface%2FTriggerFail/pipeline"

# Doing it as per the trigger variable documentation
curl -X POST --header "Private-Token: Fp_crazaAzBpaY-CCps7" -F ref=master -F "variables[MY_VARIABLE]=FOO" "https://gitlab.com/api/v4/projects/BuggyMcBugface%2FTriggerFail/pipeline"

# Maybe it likes actual JSON?
curl -X POST --header "Private-Token: Fp_crazaAzBpaY-CCps7" -F "variables=[{'key': 'MY_VARIABLE', 'value': 'foo' }]"  -F "ref=master" "https://gitlab.com/api/v4/projects/BuggyMcBugface%2FTriggerFail/pipeline"

While we're on this subject, is there any reason why the syntax for trigger variables differs from the syntax for specifying variables through the projects/:id/pipeline API? This seems unnecessarily confusing.

The former uses variables[example]=foo, but the other (apparently) wants [{ 'key' => 'example', 'value' => 'foo'}].

So:

  • Am I doing something wrong? If so, you probably want to avoid hanging to so long and ideally yield a nicer error.
  • Is it just broken?
  • Consider unifying the API formats for variable passing.
Edited by 🤖 GitLab Bot 🤖