Error "VARIABLE_SERVICE_PUT_REPOSITORY_VARIABLE failed and fallback failed" when trying to update a repository pipeline variable
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
When trying to update a pipeline deployment variable via API the following error is thrown:
1
2
3
4
5
6
7
8
9
10
{
"message": "VARIABLE_SERVICE_PUT_REPOSITORY_VARIABLE failed and fallback failed."
"arguments":
{
"spanId": "994301a815621978"
"parentSpanId": "0000000000000000"
"traceId": "994301a815621978"
}
"key": "Internal Server Error"
}
This happens because the uuid of the variable wasn't properly encoded.
Environment
Bitbucket Cloud
Diagnosis
The following 500 error is thrown when trying the API call:
1
2
3
4
5
6
7
8
9
10
{
"message": "VARIABLE_SERVICE_PUT_REPOSITORY_VARIABLE failed and fallback failed."
"arguments":
{
"spanId": "994301a815621978"
"parentSpanId": "0000000000000000"
"traceId": "994301a815621978"
}
"key": "Internal Server Error"
}
Cause
The error happens when the system can't properly read the uuid, usually because the encoding of the uuid wasn't properly parsed.
Solution
When making the API call we can start the uuid with "%7B" and end it with "%7D", which are the URL encoding for "{" and "}" respectively. So using this PUT request as an example:
1
https://api.bitbucket.org/2.0/repositories/<workspace>/<repo_slug>/pipelines_config/variables/<variable_uuid>
If our workspace is named "Atlassian", our repository is "testrepo" and the variable uuid is "123" the call would look like this:
1
https://api.bitbucket.org/2.0/repositories/atlassian/testrepo/pipelines_config/variables/%7B123%7D
This guarantees that the parsing of the URL will be correct, as not all interpreters will be able to correctly parse "{" and "}".
ℹ️ This works for any API request requiring a UUID to be passed within curly brackets on the URL itself.
Was this helpful?