Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packagist invalid response data for package version, but only on one repo #7779

Closed
caendesilva opened this issue Mar 25, 2022 · 5 comments · Fixed by #7782
Closed

Packagist invalid response data for package version, but only on one repo #7779

caendesilva opened this issue Mar 25, 2022 · 5 comments · Fixed by #7782
Labels
bug Bugs in badges and the frontend service-badge New or updated service badge

Comments

@caendesilva
Copy link

caendesilva commented Mar 25, 2022

Are you experiencing an issue with...

shields.io

🐞 Description

I have two packages on packagist that I am using version shields for. I first thought this was some caching issue, but it's been a few days and it's still the same.

On one of the packages it works perfectly, but the second badge gives the invalid response data error.

image
image

Any ideas on what's wrong and how to fix?

🔗 Link to the badge

https://img.shields.io/packagist/v/hyde/framework

💡 Possible Solution

Edit: Managed to get it to work by adding the flag ?include_prereleases. Not sure why it works well on the other one without including prereleases.

@caendesilva caendesilva added the question Support questions, usage questions, unconfirmed bugs, discussions, ideas label Mar 25, 2022
@caendesilva
Copy link
Author

Managed to get it to work by adding the flag ?include_prereleases. Not sure why it works well on the other one without including prereleases.

@chris48s
Copy link
Member

I'm going to re-open this as a bug.

https://img.shields.io/packagist/v/hyde/framework is failing with
ValidationError: "packages.hyde/framework[9].require" must be of type object

Example response that reproduces the error
{
  "minified": "composer/2.0",
  "packages": {
    "hyde/framework": [
      {
        "name": "hyde/framework",
        "description": "The HydePHP Framework",
        "keywords": [],
        "homepage": "",
        "version": "v0.5.3-alpha",
        "version_normalized": "0.5.3.0-alpha",
        "license": [
          "MIT"
        ],
        "authors": [
          {
            "name": "Caen De Silva",
            "email": "caen@desilva.se"
          }
        ],
        "source": {
          "url": "https://github.com/hydephp/framework.git",
          "type": "git",
          "reference": "40e04660ddc345053adde82ca769264a123391a1"
        },
        "dist": {
          "url": "https://api.github.com/repos/hydephp/framework/zipball/40e04660ddc345053adde82ca769264a123391a1",
          "type": "zip",
          "shasum": "",
          "reference": "40e04660ddc345053adde82ca769264a123391a1"
        },
        "type": "library",
        "time": "2022-03-26T13:53:25+00:00",
        "autoload": {
          "psr-4": {
            "Hyde\\Framework\\": "src/"
          }
        },
        "require": {
          "php": "^8.0",
          "illuminate/support": "^9.5",
          "symfony/yaml": "^6.0",
          "laravel-zero/framework": "^9.1",
          "league/commonmark": "^2.2"
        },
        "suggest": {
          "hyde/hyde": "The Framework package contains the Hyde Core. To create your site you should use the Hyde/Hyde project.",
          "torchlight/torchlight-commonmark": "Hyde has automatic support for the Torchlight syntax highlighting API which is highly reccomended if your site uses code snippets."
        },
        "support": {
          "issues": "https://github.com/hydephp/framework/issues",
          "source": "https://github.com/hydephp/framework/tree/v0.5.3-alpha"
        }
      },
      {
        "version": "v0.5.2-alpha",
        "version_normalized": "0.5.2.0-alpha",
        "source": {
          "url": "https://github.com/hydephp/framework.git",
          "type": "git",
          "reference": "bcfde31152b2b790f8d3dc73d1885babeb07047e"
        },
        "dist": {
          "url": "https://api.github.com/repos/hydephp/framework/zipball/bcfde31152b2b790f8d3dc73d1885babeb07047e",
          "type": "zip",
          "shasum": "",
          "reference": "bcfde31152b2b790f8d3dc73d1885babeb07047e"
        },
        "time": "2022-03-25T16:51:51+00:00",
        "support": {
          "issues": "https://github.com/hydephp/framework/issues",
          "source": "https://github.com/hydephp/framework/tree/v0.5.2-alpha"
        }
      },
      {
        "version": "v0.5.1-alpha",
        "version_normalized": "0.5.1.0-alpha",
        "source": {
          "url": "https://github.com/hydephp/framework.git",
          "type": "git",
          "reference": "c96105319ccca134f87a4552bb67754b78f9cb75"
        },
        "dist": {
          "url": "https://api.github.com/repos/hydephp/framework/zipball/c96105319ccca134f87a4552bb67754b78f9cb75",
          "type": "zip",
          "shasum": "",
          "reference": "c96105319ccca134f87a4552bb67754b78f9cb75"
        },
        "time": "2022-03-24T21:08:20+00:00",
        "support": {
          "issues": "https://github.com/hydephp/framework/issues",
          "source": "https://github.com/hydephp/framework/tree/v0.5.1-alpha"
        }
      },
      {
        "version": "v0.5.0-alpha",
        "version_normalized": "0.5.0.0-alpha",
        "source": {
          "url": "https://github.com/hydephp/framework.git",
          "type": "git",
          "reference": "2c29bd2b6a64930849d9d9ac24f14be65f857f43"
        },
        "dist": {
          "url": "https://api.github.com/repos/hydephp/framework/zipball/2c29bd2b6a64930849d9d9ac24f14be65f857f43",
          "type": "zip",
          "shasum": "",
          "reference": "2c29bd2b6a64930849d9d9ac24f14be65f857f43"
        },
        "time": "2022-03-24T19:08:36+00:00",
        "support": {
          "issues": "https://github.com/hydephp/framework/issues",
          "source": "https://github.com/hydephp/framework/tree/v0.5.0-alpha"
        }
      },
      {
        "version": "v0.4.3-alpha",
        "version_normalized": "0.4.3.0-alpha",
        "source": {
          "url": "https://github.com/hydephp/framework.git",
          "type": "git",
          "reference": "465bafc59fd0d20c5df91148d148d4c89a36e988"
        },
        "dist": {
          "url": "https://api.github.com/repos/hydephp/framework/zipball/465bafc59fd0d20c5df91148d148d4c89a36e988",
          "type": "zip",
          "shasum": "",
          "reference": "465bafc59fd0d20c5df91148d148d4c89a36e988"
        },
        "time": "2022-03-23T16:45:56+00:00",
        "require": {
          "php": "^8.0"
        },
        "suggest": {
          "hyde/hyde": "The Framework package contains the Hyde Core. To create your site you should use the Hyde/Hyde project."
        },
        "support": {
          "issues": "https://github.com/hydephp/framework/issues",
          "source": "https://github.com/hydephp/framework/tree/v0.4.3-alpha"
        }
      },
      {
        "version": "v0.4.2-alpha",
        "version_normalized": "0.4.2.0-alpha",
        "source": {
          "url": "https://github.com/hydephp/framework.git",
          "type": "git",
          "reference": "660810eb3d7be4f46bdf171e94bf2fdcbac94bee"
        },
        "dist": {
          "url": "https://api.github.com/repos/hydephp/framework/zipball/660810eb3d7be4f46bdf171e94bf2fdcbac94bee",
          "type": "zip",
          "shasum": "",
          "reference": "660810eb3d7be4f46bdf171e94bf2fdcbac94bee"
        },
        "time": "2022-03-23T15:44:16+00:00",
        "support": {
          "issues": "https://github.com/hydephp/framework/issues",
          "source": "https://github.com/hydephp/framework/tree/v0.4.2-alpha"
        }
      },
      {
        "version": "v0.4.1-alpha",
        "version_normalized": "0.4.1.0-alpha",
        "source": {
          "url": "https://github.com/hydephp/framework.git",
          "type": "git",
          "reference": "d7a346f5055ab9b817175ad2157302ff9eb4d7f5"
        },
        "dist": {
          "url": "https://api.github.com/repos/hydephp/framework/zipball/d7a346f5055ab9b817175ad2157302ff9eb4d7f5",
          "type": "zip",
          "shasum": "",
          "reference": "d7a346f5055ab9b817175ad2157302ff9eb4d7f5"
        },
        "time": "2022-03-22T21:27:16+00:00",
        "support": {
          "issues": "https://github.com/hydephp/framework/issues",
          "source": "https://github.com/hydephp/framework/tree/v0.4.1-alpha"
        }
      },
      {
        "version": "v0.4.0-alpha",
        "version_normalized": "0.4.0.0-alpha",
        "source": {
          "url": "https://github.com/hydephp/framework.git",
          "type": "git",
          "reference": "445fc758751acd1906bf7692e5c27723e6117495"
        },
        "dist": {
          "url": "https://api.github.com/repos/hydephp/framework/zipball/445fc758751acd1906bf7692e5c27723e6117495",
          "type": "zip",
          "shasum": "",
          "reference": "445fc758751acd1906bf7692e5c27723e6117495"
        },
        "time": "2022-03-22T18:47:45+00:00",
        "support": {
          "issues": "https://github.com/hydephp/framework/issues",
          "source": "https://github.com/hydephp/framework/tree/v0.4.0-alpha"
        }
      },
      {
        "version": "v0.3.1-alpha",
        "version_normalized": "0.3.1.0-alpha",
        "source": {
          "url": "https://github.com/hydephp/framework.git",
          "type": "git",
          "reference": "980f194a874f5d9333a12a67589c89216f2d39f2"
        },
        "dist": {
          "url": "https://api.github.com/repos/hydephp/framework/zipball/980f194a874f5d9333a12a67589c89216f2d39f2",
          "type": "zip",
          "shasum": "",
          "reference": "980f194a874f5d9333a12a67589c89216f2d39f2"
        },
        "time": "2022-03-22T12:07:15+00:00",
        "support": {
          "issues": "https://github.com/hydephp/framework/issues",
          "source": "https://github.com/hydephp/framework/tree/v0.3.1-alpha"
        }
      },
      {
        "version": "v0.3.0-alpha",
        "version_normalized": "0.3.0.0-alpha",
        "source": {
          "url": "https://github.com/hydephp/framework.git",
          "type": "git",
          "reference": "b4124be6fc1175c716483a4b842d70f676aab8aa"
        },
        "dist": {
          "url": "https://api.github.com/repos/hydephp/framework/zipball/b4124be6fc1175c716483a4b842d70f676aab8aa",
          "type": "zip",
          "shasum": "",
          "reference": "b4124be6fc1175c716483a4b842d70f676aab8aa"
        },
        "time": "2022-03-21T21:45:35+00:00",
        "support": {
          "issues": "https://github.com/hydephp/framework/issues",
          "source": "https://github.com/hydephp/framework/tree/v0.3.0-alpha"
        },
        "require": "__unset",
        "suggest": "__unset"
      }
    ]
  }
}

@chris48s chris48s reopened this Mar 26, 2022
@chris48s chris48s added bug Bugs in badges and the frontend service-badge New or updated service badge and removed question Support questions, usage questions, unconfirmed bugs, discussions, ideas labels Mar 26, 2022
@caendesilva
Copy link
Author

Hmm okay, thanks for reopening this @chris48s! Do you think the problem is on my end or with Packagist, or Shields? I see the normalized version looks very wonky 0.5.3.0-alpha.

Where is the JSON response from?

@chris48s
Copy link
Member

The normalized version looks normal for packagist.
The API response is from https://packagist.org/p2/hyde/framework.json
This bug is in our validation of the response - we're expecting require to always be an object. It is complaining about "require": "__unset" in

{
  "version": "v0.3.0-alpha",
  "version_normalized": "0.3.0.0-alpha",
  "source": {
    "url": "https://github.com/hydephp/framework.git",
    "type": "git",
    "reference": "b4124be6fc1175c716483a4b842d70f676aab8aa"
  },
  "dist": {
    "url": "https://api.github.com/repos/hydephp/framework/zipball/b4124be6fc1175c716483a4b842d70f676aab8aa",
    "type": "zip",
    "shasum": "",
    "reference": "b4124be6fc1175c716483a4b842d70f676aab8aa"
  },
  "time": "2022-03-21T21:45:35+00:00",
  "support": {
    "issues": "https://github.com/hydephp/framework/issues",
    "source": "https://github.com/hydephp/framework/tree/v0.3.0-alpha"
  },
  "require": "__unset",
  "suggest": "__unset"
}

I'm not sure whether the solution is to loosen that schema or split the schema for package version and php version. I've not had a chance to look into it yet.

@caendesilva
Copy link
Author

Oh I see. Thanks for teaching me! Let me know if I can help in any way 🙂

chris48s added a commit to chris48s/shields that referenced this issue Mar 27, 2022
repo-ranger bot added a commit that referenced this issue Mar 28, 2022
* never check for 'require' key in [packagist] /v badge

always use `schema`
closes #7779

* accept str '__unset' for 'require' key in [packagist] /php-v badge

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs in badges and the frontend service-badge New or updated service badge
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants