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

fix(pypi): lookup simple api first #26505

Closed
wants to merge 12 commits into from

Conversation

Kakadus
Copy link
Contributor

@Kakadus Kakadus commented Jan 4, 2024

Changes

This rewrites the getReleases function of pypi datasources:
First, the the simple (pypi) api is queried, then the pypijson api is retried on 404s or to enrich the metadata.
For that, I adapted the formerly named getDependencies functions to add their resolved data to an existing Result.

Previously, the simple api was only used, if pypijson returned 404.

The unit tests stayed mostly the same, but the simple api routes needed to be mocked. Also added testcases to check that both simple and json pypi apis are used, and dependency resolution succeeds if json api is unavailable.

Context

Closes #26483.

As pypijson is used additionally, #26383 is resolved as well.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@Kakadus Kakadus requested a review from secustor January 5, 2024 19:24
}
return dependency;
// merge results
return Object.assign({}, simpleDependencies, pypiJsonDependencies);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return Object.assign({}, simpleDependencies, pypiJsonDependencies);
return {
...simpleDependencies,
...pypiJsonDependencies
};

Will all pypiJsonDependencies the same information as the simple ones.
As this will overwrite releases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Maybe concatenating the found releases is better? If I saw it correctly, the dependencies should be de-duplicated later

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to deduplicate in the datasource

@Kakadus Kakadus requested a review from secustor January 6, 2024 17:23
@Kakadus Kakadus requested a review from viceice January 8, 2024 00:06
@mikecook

This comment has been minimized.

@viceice viceice marked this pull request as draft March 15, 2024 21:36
simpleHostUrl,
).catch((err) => {
if (err.statusCode !== 404) {
throw err;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be too aggressive. Custom registries can sometimes return weird things and we don't necessarily want to give up

Comment on lines +79 to +84
// merge results
return {
releases: [],
...simpleDependencies,
...pypiJsonDependencies,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should dedupe first

@rarkins
Copy link
Collaborator

rarkins commented Jul 23, 2024

@Kakadus do you have any time to resume this PR?

@rarkins
Copy link
Collaborator

rarkins commented Aug 21, 2024

Closing due to inactivity and conflicts. Reopening or replacing this PR in future would be welcomed

@rarkins rarkins closed this Aug 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PyPI datasource fall back to simple API if JSON API fails
5 participants