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

No 404 http code when the image doesn't exist ? #22

Open
MarcAgate opened this issue Sep 6, 2018 · 3 comments
Open

No 404 http code when the image doesn't exist ? #22

MarcAgate opened this issue Sep 6, 2018 · 3 comments

Comments

@MarcAgate
Copy link

When I use a wrong identifier in both endpoints of IIIFImageApiController, I get a 500 error instead of the expected 404.
Looking at IIIFImageApiController implementation I see that both endpoints return either a 200 code or (if anything fails in ImageService) throw an exception that results in a 500 error. (When the identifier is wrong, the exception comes from getInputStream() method in the ResourceRepository implementation that throws a ResourceIOException).

However, the spec (https://iiif.io/api/image/2.1/#server-responses) says it should return a 400 not found when "The image resource specified by identifier does not exist, the value of one or more of the parameters is not supported for this image, or the requested size is greater than the limits specified."

Am I missing something or is there something here that should be fixed ?

@MarcAgate
Copy link
Author

MarcAgate commented Oct 23, 2018

While digging this issue more and more, I realized that the only way to get a 404 in the actual implementation is the method
public Instant getImageModificationDate(String identifier) throws ResourceNotFoundException

in ImageService. However, ImageService relies on ResourceService to get a resource and ResourceService, whose methods are (among other things) in charge of retreiving resources, only throws ResourceIOException.

We suggest to modify the signatures of the methods retreiving resources in ResourceServices so we can distinguish the reason of the service failure at the client level (and conform to iiif specs).

Here is what we did : https://github.com/BuddhistDigitalResourceCenter/buda-iiif-server/blob/master/src/main/java/de/digitalcollections/core/backend/api/resource/ResourceRepository.java

which leads to the following implementation (using s3 storage): https://github.com/BuddhistDigitalResourceCenter/buda-iiif-server/blob/master/src/main/java/de/digitalcollections/iiif/myhymir/backend/impl/repository/S3ResourceRepositoryImpl.java

(see in particular the implementation of public InputStream getInputStream(Resource r))

What do you think ?

@datazuul
Copy link
Contributor

you are right. it will be part of upcoming 4.0.0 release

@eroux
Copy link

eroux commented Mar 2, 2019

thanks for the fix, will there be also support for 401 and 403? that would be very helpful for the auth API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants