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: set a License default value per Template #237

Closed
AlexD10S opened this issue Jul 2, 2024 · 3 comments · Fixed by #299
Closed

fix: set a License default value per Template #237

AlexD10S opened this issue Jul 2, 2024 · 3 comments · Fixed by #299
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@AlexD10S
Copy link
Collaborator

AlexD10S commented Jul 2, 2024

In the pop new parachain command, we fetch the license of the template the user is going to use.

   Pop CLI : Generate a parachain
│
◇  Select a template provider: 
│  OpenZeppelin 
│
◇  Select the type of parachain:
│  Generic Runtime Template 
│
⚙  Template License: GPL-3.0
│  

In case of the user surpass the GitHub API limit when generating the parachain it throws an error:

Error: HTTP status client error (403 Forbidden) for url (https://github.com/gitapi/repos/org/project/license)

The limit is very high so is unlikely to happen, but it looks bad to throw an error because we can't fetch the license. My suggestion is to have a default value for each template. If the API call fails, we use this default value.
Alternatively, if we want to be very strict about this and don't want to return a default value, we can return an error string, but it shouldn't stop the parachain generation.

The error is thrown here: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-common/src/git.rs#L219

@AlexD10S AlexD10S added the bug Something isn't working label Jul 2, 2024
@AlexD10S AlexD10S added the good first issue Good for newcomers label Jul 14, 2024
@aaronbassett
Copy link

I just hit this rate limit and wasn't doing anything too excessive. I was attempting to view the differences in some of the templates. It was on the 3rd pop new parachain call in around 15 mins that I received the error.

The primary rate limit for unauthenticated requests is quite low, 60 requests per hour. I do not think I exceeded that, but I might have exceeded the secondary rate limit as it appears that each time the pop new parachain command is run it can generate multiple requests in a short period of time.

My suggestion is to have a default value for each template. If the API call fails, we use this default value.

I would suggest not using the GitHub API at all. Clone and cache each of the template repositories. You can query these repositories to get the tags, their Cargo.toml files will include their license, and so on. Stale caches could be updated by pulling changes whenever a user runs pop new parachain and by providing a pop update cache command alongside the pop clean cache

@aaronbassett
Copy link

As an extra note, the rate-limiting isn't a rolling period or similar. I was limited over an hour ago, and I'm still getting the same error. It could be that the lockout period is greater than an hour, or the lockout timer resets if you attempt another request during the lockout period, or pop new parachain can sometimes cause an immediate lockout in a single run.

I don't think it is the latter as I tried multiple times from different IP addresses (VPN) and wasn't able to trigger the lockout again with a single pop new parachain run. Although, YMMV.

@AlexD10S
Copy link
Collaborator Author

Aaron, apologies for the delay on this. I've implemented a fix in this PR to limit the number of queries.

Regarding your suggestion to avoid using the GitHub API by cloning the repo directly, that approach won't work in our case. We're performing these queries before cloning the repo, when displaying the available templates to the users and allowing them to choose which one they want to clone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants