scalacenter / scaladex

The Scala Package Index
https://index.scala-lang.org
BSD 3-Clause "New" or "Revised" License
195 stars 76 forks source link

[Bug] JSON error message when project has no readme #1285

Closed bishabosha closed 8 months ago

bishabosha commented 10 months ago

Current behavior

https://index.scala-lang.org/ruimo/csvparser

Screenshot 2023-09-30 at 11 20 39

Indeed the project as of writing has no readme on github

Expected Behavior

Perhaps fill the panel with "No README found for this project, please check the repository"

Extra comments

No response

Search terms

README, error message

adpi2 commented 10 months ago

Thanks for the report. Would you like to submit a PR? :)

mfirry commented 8 months ago

Could this be solved by adding something like case HttpResponse(StatusCodes.NotFound, headers, entity, _) => in here?

adpi2 commented 8 months ago

@mfirry Thanks for jumping into this. The issue is here: https://github.com/scalacenter/scaladex/blob/13ec905ae2b509b58e7c95235e17a5347552b312/modules/webclient/src/main/scala/scaladex/client/Client.scala#L43-L52

At the client side, we send a request to Github to get the readme but we don't check the status code.

mfirry commented 8 months ago

Ok so something along these lines would work for you?

    fetch(request).toFuture
      .flatMap { res =>
        if(res.status == 200) {
          res.text().toFuture
        } else {
          Future("No README found for this project, please check the repository")
        }
adpi2 commented 8 months ago

Ok so something along these lines would work for you?

Yep it looks good