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

error when requesting additional fields #101

Open
tacman opened this issue Jan 28, 2024 · 5 comments
Open

error when requesting additional fields #101

tacman opened this issue Jan 28, 2024 · 5 comments
Labels

Comments

@tacman
Copy link
Contributor

tacman commented Jan 28, 2024

$client->all(['fields' => ['abandoned','repository','type']);

image

Generates an error because source isn't set in $version:

image

I'll submit a PR

tacman added a commit to tacman/packagist-api that referenced this issue Jan 28, 2024
@tacman
Copy link
Contributor Author

tacman commented Jan 28, 2024

Actually, my PR isn't sufficient.

The problem is that the return value when passing 'fields' to list.json is an array of those fields.

    public function createPackageResults(array $package): Package
    {
        dd($package);

returns

image

@robbieaverill
Copy link
Collaborator

Hi @tacman, would you be interested in submitting another PR to fix this?

@tacman
Copy link
Contributor Author

tacman commented Mar 14, 2024

Can you point me in the right direction? For the project I was working on, I simply filtered them after retrieving.

@robbieaverill
Copy link
Collaborator

It seems like the error is caused by the code expecting the 'source' key to exist. In your example you're filtering fields and 'source' isn't one of those included. Perhaps a change like this might be sufficient to fix the issue:

- if ($version['source']) {
+ if (!empty($version['source'])) {

@tacman
Copy link
Contributor Author

tacman commented Mar 14, 2024

That's what I did in #102, but it wasn't enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants