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

Handle Modrinth API returning 404s randomly #3276

Open
sleiphir opened this issue Jan 23, 2025 · 7 comments
Open

Handle Modrinth API returning 404s randomly #3276

sleiphir opened this issue Jan 23, 2025 · 7 comments

Comments

@sleiphir
Copy link

Enhancement Type

Improve an existing feature

Describe the enhancement

Here are linked modrinth issues
modrinth/code#2421
modrinth/code#2557

For some projects the Modrinth API will randomly return either a 404 or the expected JSON content that's used to determine what to download when using MODRINTH_PROJECT

As these issues have been opened for a little while I was wondering if there was anything that could be done to circumvent this problem. I'm not familiar with Modrinth's API so I don't know if there are any fallback routes that could be used.

Here is the issue that I get:

[mc-image-helper] 15:46:00.009 ERROR : 'modrinth' command failed. Version is 1.40.11
me.itzg.helpers.http.FailedRequestException: HTTP request of https://api.modrinth.com/v2/project/MdwFAVRL/version?loaders=%5B%22fabric%22%5D&game_versions=%5B%221.21.1%22%5D failed with 404 Not Found: Fetching object content

Trying to load the URL manually we can see that it sometimes displays the JSON and sometimes a 404.

Also, I don't think it's entirely random as trying to read the headers using curl I ALWAYS get a 404:

curl -I "https://api.modrinth.com/v2/project/MdwFAVRL/version?loaders=%5B%22fabric%22%5D&game_versions=%5B%221.21.1%22%5D"

But not using -I and reading the response directly works most of the time in my case.

For now I can solve the problem by manually adding this mod to my server but I want people to be aware that this is a thing.

@itzg
Copy link
Owner

itzg commented Jan 23, 2025

I'm not sure if there's anything I can do. The behavior of 3rd party APIs is beyond my control.

Thanks for researching and linking to their issues. I think all we can do is wait for them to fix those issues.

@sleiphir
Copy link
Author

I guess there is not much we can do indeed, maybe adding a disclaimer to the MODRINTH_PROJECT option would help redirect users to better solutions early. Until Modrinth looks into it further which might never happen.

@sleiphir
Copy link
Author

I found that the /v2/projects endpoint does not have this problem.

Calling https://api.modrinth.com/v2/projects?ids=%5B%22MdwFAVRL%22%5D always works, but I don't know if it can be adapted to work the same way /v2/project is being used right now.

@itzg
Copy link
Owner

itzg commented Jan 23, 2025

I found that the /v2/projects endpoint does not have this problem.

Calling https://api.modrinth.com/v2/projects?ids=%5B%22MdwFAVRL%22%5D always works, but I don't know if it can be adapted to work the same way /v2/project is being used right now.

The image tooling is already using /v2/projects and is not using /v2/project. It's using https://docs.modrinth.com/api/operations/getproject/ if that's what you mean...but the two endpoints serve different purposes so the code can't just arbitrarily call one instead of the other.

maybe adding a disclaimer to the MODRINTH_PROJECT option would help redirect users to better solutions early

Your issue is the first I'm hearing of any of this, so I am quite hesitant to put a documentation level disclaimer at this point. If I start hearing of numerous users running into this, then I can reconsider. BTW, what "better solutions" do you propose?

@sleiphir
Copy link
Author

If we look at the issues I linked to in my first message we can see this has been a problem for some people for at least the past 6 months. Now the issue is that I don't know the actual size of 'some people' I only know 3 of them. Maybe a first step would be for you to try to call https://api.modrinth.com/v2/project/MdwFAVRL/version?loaders=%5B%22fabric%22%5D&game_versions=%5B%221.21.1%22%5D a few times and see if you ever get a 404, it happens about 1/3rd of the time for me.

@Qirivaal
Copy link

I'm having this issue as well

@itzg
Copy link
Owner

itzg commented Jan 31, 2025

Everyone, please add comments and upvote the linked issues. The only solution is to get Modrinth's attention on this to fix it.

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

No branches or pull requests

3 participants