foojayio / discoapi

The foojay discovery api (discoapi) is made to discover java packages (jre/jdk) from different distributions.
GNU General Public License v2.0
112 stars 13 forks source link

API v2 is returning 404 for some resources #60

Closed andreaTP closed 2 years ago

andreaTP commented 2 years ago

A previously working link like: https://api.foojay.io/disco/v2.0/directuris?distro=temurin&javafx_bundled=false&libc_type=libc&archive_type=tar.gz&operating_system=mac&package_type=jdk&version=19&architecture=x64&latest=available

Is now consistently returning 404. Is it expected? Is there a direct migration path from v2 to v3 that doesn't involve parsing json as mentioned here ?

HanSolo commented 2 years ago

Well if you request an early access build you have to specify that by using "release_status=ea". The endpoint assumes the request of "ga" builds. So your link will work when using version=18 because it has release_status=ga but 19 is still early access which means you need to add "release_status=ea" to make it work. You could also directly switch to v3.0, the following link should work: https://api.foojay.io/disco/v3.0/directuris?distro=temurin&javafx_bundled=false&libc_type=libc&archive_type=tar.gz&operating_system=mac&package_type=jdk&version=19&architecture=x64&latest=available&release_status=ea

andreaTP commented 2 years ago

@HanSolo thanks a lot for the fast feedback!

Is it possible to specify a wildcard release_status=ea,ga? It looks to be working with v3 but not with v2

HanSolo commented 2 years ago

you can add &release_status=ea&release_status=ga which will return both

andreaTP commented 2 years ago

Thanks! 🎉

andreaTP commented 2 years ago

@HanSolo sorry for bothering, I tested it and it doesn't look to work as expected:

e.g.: https://api.foojay.io/disco/v2.0/directuris?distro=temurin&javafx_bundled=false&libc_type=libc&archive_type=tar.gz&operating_system=mac&package_type=jdk&version=19&architecture=x64&latest=available&release_status=ea&release_status=ga

still returns 404. Am I doing something wrong?

quintesse commented 2 years ago

@HanSolo could this possibly be a regression? I'm pretty sure that some months ago I tested it and made sure that not specifying the release status would actually make sure I'd always get some result, either GA or EA. (See https://github.com/jbangdev/jbang/commit/047f51adf1705a4c27ea7342132c2accd2b0293e) Or could it perhaps be a difference between v2 and v3?

HanSolo commented 2 years ago

will check…

HanSolo commented 2 years ago

There us definitely something wrong, sometimes it works and sometimes not. Will fix it asap

HanSolo commented 2 years ago

Checked the code again and saw that I was wrong, you cannot use "ea" and "ga" at the same time. I made some modifications so that the behavior will be as follows: if you provide release_status, it will be taken...no matter what, which means if you try to get a direct uri for a jdk 19 and set release_status=ga...you won't get anything because 19 is still ea. So I've modified the detection of the release_status in the way that if you request jdk 19 and do not set release_status, the api will figure out the current release_status of jdk 19 (in this case ea) and will use release_status=ea automatically. In case you request jdk 18 and don't provide release_status, the api will use release_status=ga automatically. If you would like to retrieve an ea version of jdk 18 you need to specifiy release_status=ea. Long story short...usually you should not need to set the release_status for the /directuris endpoint. I will deploy the version now to staging and if it works as expected to production later today. So it should be available later today.

andreaTP commented 2 years ago

Thanks @HanSolo , this should restore the original behavior in jbang without the need for code changes. Let us know when is deployed so that we can test it!

HanSolo commented 2 years ago

It is deployed...so you can test it now in 2.0 and 3.0

andreaTP commented 2 years ago

Thanks, @HanSolo really appreciated! Tested and it works as expected!

quintesse commented 2 years ago

Thank you for the quick fix @HanSolo ! We really appreciate it. 🎉

HanSolo commented 2 years ago

Glad it works as expected :)