Describe the bug
Apologies in advance if this is not the right place to put it. After spending hours tracking down this bug, it seems to be a combination of multiple things, but the simplest solution I think is to update kt-paperclip.
When using temporary credentials, AWS generates pre-signed URLs that include a very long X-Amz-Security-Token, bringing the total length of the URL to greater than an implicit character limit that ImageMagick's identify seem to have. In our particular case, the limit was about 1030 characters. Any call to identify <URL> where URL is greater than this LIMIT would cause identify to throw the error "identify: unable to create temporary file", which causes everything that relies on it (including calls from kt-paperclip's Geometry#from_file) to fail.
To Reproduce
Steps to reproduce the behavior using just the command line:
Install Amazon Linux 2023 (6.1.79-99.164.amzn2023.aarch64)
Install ImageMagick (I'm using the latest 7.1.1-32)
Run in bash: identify "<URL>" where <URL> is a really long URL. A simple example is below:
identify "https://www.google.com/logos/doodles/2024/celebrating-hank-adams-6753651837110220-s.png?test=" worked
identify "https://www.google.com/logos/doodles/2024/celebrating-hank-adams-6753651837110220-s.png?test=<insert 800 spaces>" worked
identify "https://www.google.com/logos/doodles/2024/celebrating-hank-adams-6753651837110220-s.png?test=<insert 1100 spaces>" did not work
See error "identify: unable to create temporary file"
Expected behavior
It should not have an error, but return some info about the file at the URL, including its format and size.
Additional context
I suspect the problem is in identify's way of handling arguments, but I haven't dug into the ImageMagick source. Since so many people run different versions of ImageMagick, it may be easier to solve this problem by updating kt-paperclip. Specifically, in Geometry#from_file, one can write the contents of the remote file to a Tempfile, and then pass the Tempfile to GeometryDetector rather than passing in the URL directly.
Describe the bug Apologies in advance if this is not the right place to put it. After spending hours tracking down this bug, it seems to be a combination of multiple things, but the simplest solution I think is to update kt-paperclip.
When using temporary credentials, AWS generates pre-signed URLs that include a very long X-Amz-Security-Token, bringing the total length of the URL to greater than an implicit character limit that ImageMagick's
identify
seem to have. In our particular case, the limit was about 1030 characters. Any call toidentify <URL>
where URL is greater than this LIMIT would causeidentify
to throw the error "identify: unable to create temporary file", which causes everything that relies on it (including calls from kt-paperclip'sGeometry#from_file
) to fail.To Reproduce Steps to reproduce the behavior using just the command line:
identify "<URL>"
where<URL>
is a really long URL. A simple example is below:identify "https://www.google.com/logos/doodles/2024/celebrating-hank-adams-6753651837110220-s.png?test="
workedidentify "https://www.google.com/logos/doodles/2024/celebrating-hank-adams-6753651837110220-s.png?test=<insert 800 spaces>"
workedidentify "https://www.google.com/logos/doodles/2024/celebrating-hank-adams-6753651837110220-s.png?test=<insert 1100 spaces>"
did not workExpected behavior It should not have an error, but return some info about the file at the URL, including its format and size.
Additional context I suspect the problem is in
identify
's way of handling arguments, but I haven't dug into the ImageMagick source. Since so many people run different versions of ImageMagick, it may be easier to solve this problem by updating kt-paperclip. Specifically, inGeometry#from_file
, one can write the contents of the remote file to a Tempfile, and then pass the Tempfile toGeometryDetector
rather than passing in the URL directly.