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

"fit-in" segment in the url path generates 404 "code":"NoSuchKey" #281

Closed
tzcccc opened this issue Apr 16, 2021 · 5 comments
Closed

"fit-in" segment in the url path generates 404 "code":"NoSuchKey" #281

tzcccc opened this issue Apr 16, 2021 · 5 comments
Labels

Comments

@tzcccc
Copy link

tzcccc commented Apr 16, 2021

Describe the bug
If file url contains "fit-in" segment, file not found for processing.

To Reproduce

  • save and try to process jpeg file as "my.domain.com/400x0/fit-in-den-fruehling-wandern.jpeg"
  • returning {"status":404,"code":"NoSuchKey","message":"The specified key does not exist."}

Expected behavior
image will be found and processed correctly

Please complete the following information about the solution:

  • version v5.2.0
@tzcccc tzcccc added the bug label Apr 16, 2021
@beomseoklee
Copy link
Member

@tzcccc thanks for your feedback.
I've tested this case by myself, but it worked for me. This is an example link you can see.

@smknstd
Copy link

smknstd commented May 8, 2021

@beomseoklee
Copy link
Member

@smknstd Thanks for your finding, and I was able to reproduce the issue.
To fix the issue, I guess you can change the below.
https://github.com/awslabs/serverless-image-handler/blob/c5db6f7efbd6d151c31f2781c9a6c3c3c9d7d299/source/image-handler/image-request.js#L260

return decodeURIComponent(path.replace(/\/fit-in\/|\/(\d+x\d+)\/|filters:[^\)]+|^\/+/g, '').replace(/\)/g, '').replace(/^\/+/, ''));

Let us know if this can fix your issue.

@Furytron
Copy link

Furytron commented Nov 8, 2021

@beomseoklee just looking at the regex changes there, wanted to ask a question about it.

Original regex from here we can see it has broken the above examples: https://regex101.com/r/I6rOfX/1

However, with the suggested change you mentioned, it fixes the problem but the dimensions are not matched if "fit-in" is added to the URL. See: https://regex101.com/r/ZezPC6/1. This is only an issue if we want to get a grouping of the dimensions, if that isn't needed by this regex, then the fix should work.

@fisenkodv
Copy link
Contributor

@tzcccc, we have updated our solution, the issue has been fixed. If you still see the issue with the latest version (v6.0.0), please feel free to reopen the issue.

You can refer to the recent changes here.

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

No branches or pull requests

5 participants