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

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

Closed
bishabosha opened this issue Sep 30, 2023 · 5 comments · Fixed by #1303
Closed

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

bishabosha opened this issue Sep 30, 2023 · 5 comments · Fixed by #1303

Comments

@bishabosha
Copy link
Member

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
Copy link
Member

adpi2 commented Oct 2, 2023

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

@mfirry
Copy link
Contributor

mfirry commented Nov 13, 2023

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

@adpi2
Copy link
Member

adpi2 commented Nov 14, 2023

@mfirry Thanks for jumping into this. The issue is here:

val request = new Request(
s"https://api.github.com/repos/$organization/$repository/readme",
new RequestInit {
headers = headersWithCreds.toJSDictionary
}
)
fetch(request).toFuture
.flatMap(res => res.text().toFuture)
.foreach { res =>
element.innerHTML = res

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

@mfirry
Copy link
Contributor

mfirry commented Nov 14, 2023

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
Copy link
Member

adpi2 commented Nov 14, 2023

Ok so something along these lines would work for you?

Yep it looks good

adpi2 added a commit that referenced this issue Nov 14, 2023
Adding handling for repos with missing README files. Fixes #1285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants