Problem/Motivation

Right now, we don't handle the difference between "there are no results for your query" and "you have given me an invalid query." If there's a bad query (for example because you have an outdated PB client), it will just appear that you have 0 results.

Steps to reproduce

Using these links, you can get different results.

The API if there are truly 0 results:
https://drupalorg.prod.cluster.drupalsystems.org/jsonapi/index/project_m...

The API returns a 400 if you issue a bad request:
https://drupalorg.prod.cluster.drupalsystems.org/jsonapi/index/project_m...

An example good request:
https://drupalorg.prod.cluster.drupalsystems.org/jsonapi/index/project_m...

Proposed resolution

I THINK this is somewhere around here:
https://git.drupalcode.org/project/project_browser/-/blob/2.0.x/src/Plug... - someone please correct me if I'm wrong.

CommentFileSizeAuthor
#3 3494818.patch2.89 KBpfrilling
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

chrisfromredfin created an issue. See original summary.

phenaproxima’s picture

pfrilling’s picture

StatusFileSize
new2.89 KB

Attached is a patch that I started. Not entirely sure I'm on the right path. Would love some feedback and/or it can help someone else as a starting point.

fjgarlin made their first commit to this issue’s fork.

fjgarlin’s picture

It's defo a good beginning, I made it into an MR so we can continue there, give feedback, etc.
https://git.drupalcode.org/project/project_browser/-/merge_requests/651/...

fjgarlin’s picture

I simplified a bit some of the cosmetic changes. I haven't tested anything yet so I don't know how close we are to a solution.

fjgarlin’s picture

#3494819: Display warnings/errors from DrupalOrgJsonApi backend is ready for review and introduces a way to send error messages to the front-end which we may or may not use here, but I'd like validation of that approach before continuing here.

fjgarlin’s picture

Status: Active » Needs review

As the related issue was just committed, doing this is very straightforward. Ready to test.

In order to test, we could, in `DrupalDotOrgJsonApi.php`, at line 144, add any of the following:
throw new \Exception("Exception Test", 0);

Cannot trigger these two because they need additional params added by the library, but the above should be enough to prove the code here:
throw new RequestException("RequestException Test");
throw new GuzzleException("GuzzleException Test");

Then this should show into the front-end.

chrisfromredfin’s picture

Status: Needs review » Fixed

Wonderful work, y'all. This surfaced a follow-up about "caching" results, which include errors. But that's a bigger can of worms.

fjgarlin’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.