badges / shields

Concise, consistent, and legible badges in SVG and raster format
https://shields.io
Creative Commons Zero v1.0 Universal
23.67k stars 5.49k forks source link

Keeps on showing 'invalid response data' for VS Code theme extension #8026

Open sjns19 opened 2 years ago

sjns19 commented 2 years ago

Are you experiencing an issue with...

My own instance of shields

🐞 Description

I really have no idea why it's happening but this is very strange.

So, I have two themes for VS Code:

https://marketplace.visualstudio.com/items?itemName=SujanShrestha.everest-night-theme

https://marketplace.visualstudio.com/items?itemName=SujanShrestha.chrome-console-dark

The latter one was published just today and the rating and downloads badges for it keep on giving the invalid response data error. What's strange is that, it seems to be working sometimes but not always. I republished the theme like 10 times but nothing happened so I let it like that thinking it must have been some cache related issue and it's still the same.

After an hour, it did show the downloads as 2 and "no ratings" text but now the same errors are back. Another strange thing is, it's showing perfectly fine on its github repo but not on the VS Code Markeplace.

The way the package.json for both of the themes are structured, is exactly the same. Only differences are the names and versions but the badges work fine for the other theme but not for the "Chrome Console Dark" one.

I really have no idea if it's the issue from my side or the shields itself so I opened this issue.

Edit

Screenshots requested

From the marketplace:

Screen Shot 2022-06-01 at 8 40 27 PM

From github repo:

Screen Shot 2022-06-01 at 8 41 11 PM

All the badges links:

It seems, it has some kind of a problem parsing the JSOn data from the marketplace only, because I have the version linked from github's package.json and it gives no errors.

Edit 2

So now, the overall downloads at the marketplace page shows just 1 while it's showing 4 in the git repo.

Screen Shot 2022-06-01 at 8 56 41 PM

So I assume it's either the shields' problem or the marketplace's API?

🔗 Link to the badge

https://img.shields.io/visual-studio-marketplace/d/SujanShrestha.chrome-console-dark?color=%23f19767&style=for-the-badge

https://img.shields.io/visual-studio-marketplace/stars/SujanShrestha.chrome-console-dark?color=%23f19767&style=for-the-badge

💡 Possible Solution

No idea...

calebcartwright commented 2 years ago

Could you please update the issue description with all badge links, and the embedded badges so that they will render inline?

Additionally, since you say the behavior is intermittent, it would be helpful if you could capture a screenshot of the badge for reference. All we can do is speculate until we're able to reproduce the issue, but as to some of the other items:

The "invalid response data" means that the upstream API (the Marketplace in this case) returned an unexpected HTTP response structure that diverges from the typical, expected response. When this happens consistently, it's typically due to the upstream provider changing their API contract (such as removing a field we were using). If it's an intermittent occurrence though then it's possible the upstream API is having some issues and returning some kind of error-ish response.

It's also possible that there's a temporary issue that occurs shortly after publishing an updated version to the marketplace.

Finally, there's all sorts of caching layers between you and us, both more locally on your machine, on the actual rendering platforms (Marketplace vs. github.com vs. etc.), and our CDN. A straightforward way to bust these caching layers is to make a minor tweak to the badge parameters, e.g. change the style, color, label, etc. query params.

sjns19 commented 2 years ago

Hi, I have updated it as you requested. One more thing that I noticed is that, every time someone downloads my theme and the counter increases, it shows the error for a while before finally updating to the latest count again.

calebcartwright commented 2 years ago

Hi, I have updated it as you requested. One more thing that I noticed is that, every time someone downloads my theme and the counter increases, it shows the error for a while before finally updating to the latest count again.

If you are seeing this consistently, would you mind snagging the raw api response the marketplace api is returning from your package when this occurs? It's a bit of a pain to call, but it's a post to https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery/

and headers/body shown below

{
  "headers": {
    "accept": "application/json;api-version=3.0-preview.1",
    "content-type": "application/json"
  },
  "method": "POST",
  "body": "{
    "filters":[{
      "criteria":[
        {
           "filterType":7,
           "value":"yourPublisher.yourPackage"
         }
      ]}
    ],
    "flags":914
    }"
}
DiscreteTom commented 1 year ago

Hello, I encountered the same issue, the vs marketplace shows invalid response data.

Here is my request result using curl:

curl https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery/ -H "accept: application/json;api-version=3.0-preview.1" -H "content-type: application/json" -X POST --data "{\"filters\":[{\"criteria\":[{\"filterType\":7,\"value\":\"DiscreteTom.vscode-retsac\"}]}],\"flags\":914}"
{
  "results": [
    {
      "extensions": [
        {
          "publisher": {
            "publisherId": "05313ab7-1b2c-497f-a960-b9f8d7906a28",
            "publisherName": "DiscreteTom",
            "displayName": "DiscreteTom",
            "flags": "verified",
            "domain": null,
            "isDomainVerified": false
          },
          "extensionId": "a0feddb5-fde4-431d-aae5-6e672bc0418b",
          "extensionName": "vscode-retsac",
          "displayName": "vscode-retsac",
          "flags": "validated, public",
          "lastUpdated": "2023-03-11T09:45:29.403Z",
          "publishedDate": "2023-03-11T09:41:15.91Z",
          "releaseDate": "2023-03-11T09:41:15.91Z",
          "shortDescription": "VSCode extension for retsac.",
          "versions": [
            {
              "version": "0.1.0",
              "flags": "validated",
              "lastUpdated": "2023-03-11T09:45:29.403Z",
              "files": [
                {
                  "assetType": "Microsoft.VisualStudio.Code.Manifest",
                  "source": "https://discretetom.gallerycdn.vsassets.io/extensions/discretetom/vscode-retsac/0.1.0/1678527680832/Microsoft.VisualStudio.Code.Manifest"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.Content.Changelog",
                  "source": "https://discretetom.gallerycdn.vsassets.io/extensions/discretetom/vscode-retsac/0.1.0/1678527680832/Microsoft.VisualStudio.Services.Content.Changelog"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.Content.Details",
                  "source": "https://discretetom.gallerycdn.vsassets.io/extensions/discretetom/vscode-retsac/0.1.0/1678527680832/Microsoft.VisualStudio.Services.Content.Details"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.Content.License",
                  "source": "https://discretetom.gallerycdn.vsassets.io/extensions/discretetom/vscode-retsac/0.1.0/1678527680832/Microsoft.VisualStudio.Services.Content.License"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.VsixManifest",
                  "source": "https://discretetom.gallerycdn.vsassets.io/extensions/discretetom/vscode-retsac/0.1.0/1678527680832/Microsoft.VisualStudio.Services.VsixManifest"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.VSIXPackage",
                  "source": "https://discretetom.gallerycdn.vsassets.io/extensions/discretetom/vscode-retsac/0.1.0/1678527680832/Microsoft.VisualStudio.Services.VSIXPackage"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.VsixSignature",
                  "source": "https://discretetom.gallerycdn.vsassets.io/extensions/discretetom/vscode-retsac/0.1.0/1678527680832/Microsoft.VisualStudio.Services.VsixSignature"
                }
              ],
              "properties": [
                {
                  "key": "Microsoft.VisualStudio.Services.Links.Getstarted",
                  "value": "https://github.com/DiscreteTom/vscode-retsac.git"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.Links.Support",
                  "value": "https://github.com/DiscreteTom/vscode-retsac/issues"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.Links.Learn",
                  "value": "https://github.com/DiscreteTom/vscode-retsac#readme"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.Links.Source",
                  "value": "https://github.com/DiscreteTom/vscode-retsac.git"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.Links.GitHub",
                  "value": "https://github.com/DiscreteTom/vscode-retsac.git"
                },
                {
                  "key": "Microsoft.VisualStudio.Code.Engine",
                  "value": "^1.76.0"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown",
                  "value": "true"
                },
                {
                  "key": "Microsoft.VisualStudio.Code.ExtensionDependencies",
                  "value": ""
                },
                {
                  "key": "Microsoft.VisualStudio.Code.ExtensionPack",
                  "value": ""
                },
                {
                  "key": "Microsoft.VisualStudio.Code.LocalizedLanguages",
                  "value": ""
                },
                {
                  "key": "Microsoft.VisualStudio.Code.ExtensionKind",
                  "value": "ui,workspace,web"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.Content.Pricing",
                  "value": "Free"
                }
              ],
              "assetUri": "https://discretetom.gallerycdn.vsassets.io/extensions/discretetom/vscode-retsac/0.1.0/1678527680832",
              "fallbackAssetUri": "https://discretetom.gallery.vsassets.io/_apis/public/gallery/publisher/DiscreteTom/extension/vscode-retsac/0.1.0/assetbyname"
            }
          ],
          "deploymentType": 0
        }
      ],
      "pagingToken": null,
      "resultMetadata": [
        {
          "metadataType": "ResultCount",
          "metadataItems": [{ "name": "TotalCount", "count": 1 }]
        }
      ]
    }
  ]
}

As the result, I noticed there is no statistics in the response, so the issue may be cause by here.

chris48s commented 1 year ago

Interesting. I think the situation you're seeing (completely missing statistics array) is another related but slightly different bug.

For your plugin, all the badges are affected, so https://img.shields.io/visual-studio-marketplace/v/DiscreteTom.vscode-retsac https://img.shields.io/visual-studio-marketplace/last-updated/DiscreteTom.vscode-retsac https://img.shields.io/visual-studio-marketplace/d/DiscreteTom.vscode-retsac all throw the same error.

For the issue in the top post, only the downloads badge was affected.

In any case, I've submitted a PR at https://github.com/badges/shields/pull/8985 to handle the case where statistics[] is completely missing from the response.