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

As a n00b paginator, there might be an off-by-1 error in the limit parameter #73

Closed
nutjob4life opened this issue Apr 15, 2021 · 4 comments · Fixed by NASA-PDS/registry-api-service#23 or NASA-PDS/registry-api#82
Assignees
Labels
B12.0 bug Something isn't working s.medium

Comments

@nutjob4life
Copy link
Member

nutjob4life commented Apr 15, 2021

🐛 Describe the bug

The API at https://pds-gamma.jpl.nasa.gov/api/ has pagination features that include a start index and a limit described as "maximum number of matching results returned, for pagination". This is also reflected in the Swagger definition and the draft specification document.

For the /collections/{lidvid}/products endpoint, this is the case. But for the /bundles/{lidvid}/collections it returns 1 more than the limit.

📜 To Reproduce

Run curl --silent --header 'Accept: application/json' 'https://pds-gamma.jpl.nasa.gov/api/collections/urn%3Anasa%3Apds%3Ainsight_documents%3Adocument_hp3rad%3A%3A8.0/products?start=0&limit=0&fields=ops%3AData_File_Info.ops%3Amd5_checksum&only-summary=false' | json_pp and note that the limit is 0 and 0 results are returned in data ✅. limit=1 gives 1, limit=2 gives 2.

But compare that with curl --silent --header 'Accept: application/json' 'https://pds-gamma.jpl.nasa.gov/api/bundles/urn%3Anasa%3Apds%3Ainsight_documents%3A%3A2.0/collections?start=0&limit=0&fields=ops%3AData_File_Info.ops%3Amd5_checksum&only-summary=false' | json_pp and note that the limit is 0 but 1 result is the data is returned ❌. limit=1 gives 2, limit=2 gives 3, etc. limit=-1 gives 0!

🕵️ Expected behavior

Consistency in limit between endpoints.

📚 Version of Software Used

[ base url: /api/ , api version: 0.0.1 ]

🖥 System Info

  • OS: independent
  • Browser: independent
  • Version: 0.0.1

** 🦄 Applicable requirements**

@al-niessner
Copy link
Contributor

@tloubrieu-jpl What is the trick to match an endpoint in the registry code? Looking entry point(s) for the two given examples. No log messages present a crumb trail which has been my method so far.

@tloubrieu-jpl
Copy link
Member

Hi @al-niessner that is a bit intricate indeed.

Each of the controller (e.g. MyBundleApiController) implemented an interface (BundleApi).

The interface is generated by the swagger definition of the API and defines the method <-> api end-point relationships.

The easiest way to get this information is to Command-click in Eclipse, on macos (go to the declaration of the interface, for example BundleAPI, not sure how it goes on Linux). Although the source are not attached to the project, the interface prototype information is displayed, for example:

'''
@org.springframework.web.bind.annotation.RequestMapping(value={"/bundles/{lidvid}"},
produces={"application/json","application/xml","application/pds4+xml"},
method={org.springframework.web.bind.annotation.RequestMethod.GET})
public abstract org.springframework.http.ResponseEntity bundleByLidvid(@io.swagger.annotations.ApiParam(value="lidvid (urn)",
required=true) @org.springframework.web.bind.annotation.PathVariable(value="lidvid") java.lang.String lidvid);
Method Parameters:
lidvid
'''

The bold part gives you the method <--> api end-point relationship.

Feel free to add the logs in the implementation, that looks like a good practice to me. Eventually, we will make the logs consistent so that they can be used to make stats on the usage of the API so this is something we will need not only to make developers more comfortable.

Thanks

@al-niessner
Copy link
Contributor

al-niessner commented Apr 29, 2021

@tloubrieu-jpl

Couple of items:

  1. Where do I find the source for BundlesApi? When I open it in Eclipse no source is found.
  2. I added log messages to all methods in MyBundlesApiController and no output. Deleted target and did a mvn clean install. Still no messages. When try wildcard it works just find and get all logging including changes to check that updates are coming through.
  3. Not even sure any code in registry-app-service is even called by these endpoints. Since it is /api/bundle does that put it in another repository?

@tloubrieu-jpl
Copy link
Member

tloubrieu-jpl commented Apr 29, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B12.0 bug Something isn't working s.medium
Projects
None yet
4 participants