badges / shields

Concise, consistent, and legible badges in SVG and raster format

Home Page:https://shields.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bitbucket not completely finished workflow returns invalid response data

ArcherEmiya05 opened this issue Β· comments

Are you experiencing an issue with...

shields.io

🐞 Description

We have a workflow that has success step but not complete due to manual trigger, the build status badge for Bitbucket returns invalid response data

πŸ”— Link to the badge

https://img.shields.io/bitbucket/pipelines/devsbitwise/cryptonian/master?label=πŸ“¦%20CI%2FCD%20pipeline

πŸ’‘ Possible Solution

No response

Badge tested using npm run badge https://img.shields.io/bitbucket/pipelines/devsbitwise/cryptonian/master?label=πŸ“¦%20CI%2FCD%20pipeline
Output is available here

OK, so what's happening here is:

We call
https://api.bitbucket.org/2.0/repositories/devsbitwise/cryptonian/pipelines/?fields=values.state&page=1&pagelen=2&sort=-created_on&target.ref_type=BRANCH&target.ref_name=master

That returns

{
  "values": [
    {
      "state": {
        "name": "IN_PROGRESS",
        "type": "pipeline_state_in_progress",
        "stage": {
          "name": "PAUSED",
          "type": "pipeline_state_in_progress_paused"
        }
      }
    },
    {
      "state": {
        "name": "COMPLETED",
        "type": "pipeline_state_completed",
        "result": {
          "name": "SUCCESSFUL",
          "type": "pipeline_state_completed_successful"
        }
      }
    }
  ]
}

We fail validation with

"values[0].state.result" is required

so I guess we would need to make the result key optional in the schema and then adjust the code to handle the fact that property may or may not exist.

if (values.length > 0) {
return values[0].state.result.name
}