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

[4.x]: craft\errors\ImageTransformException: Failed to generate transform with id of x #13299

Closed
joepagan opened this issue Jun 8, 2023 · 2 comments
Assignees

Comments

@joepagan
Copy link

joepagan commented Jun 8, 2023

What happened?

Description

Getting this error reporting in an app for several different transforms trying to be generated over the past couple days after a recent release, though not sure exactly what has triggered it.

Steps to reproduce

  1. not sure

Expected behavior

no error.

Actual behavior

Looks like a transform in this case id 57113 cannot be generated.
Looking at that ID in imagetransformindex table, it shows no filename:
image

Potentially shows a transformString value of some dimensions which I do not believe exist anywhere currently in the codebase.
filename is NULL in this row
the asset id in question is 106616, the asset exists and the source image exists, I can view it fine in the asset manager, I can also see it rendered at another set of dimensions with another transform on a particular template.

Is there a query I can run here to find out where this transform is being generated exactly?

[2023-06-08T14:44:34.365775+00:00] app.ERROR: craft\errors\ImageTransformException: Failed to generate transform with id of 57113. in /var/www/html/cms/vendor/craftcms/cms/src/imagetransforms/ImageTransformer.php:481 
Stack trace: 
#0 /var/www/html/cms/vendor/craftcms/cms/src/imagetransforms/ImageTransformer.php(103): craft\imagetransforms\ImageTransformer->ensureTransformUrlByIndexModel() 
#1 /var/www/html/cms/vendor/craftcms/cms/src/elements/Asset.php(1589): craft\imagetransforms\ImageTransformer->getTransformUrl() 
#2 /var/www/html/cms/vendor/craftcms/cms/src/elements/Asset.php(1510): craft\elements\Asset->_url() 
#3 /var/www/html/cms/vendor/craftcms/cms/src/elements/Asset.php(1361): craft\elements\Asset->getUrl() 
#4 /var/www/html/cms/vendor/craftcms/cms/src/elements/Asset.php(1259): craft\elements\Asset->getUrlsBySize() 
#5 /var/www/html/cms/vendor/twig/twig/src/Extension/CoreExtension.php(1607): craft\elements\Asset->getSrcset() 
#6 /var/www/html/cms/vendor/craftcms/cms/src/helpers/Template.php(110): twig_get_attribute() 
#7 /var/www/html/cms/storage/runtime/compiled_templates/f8/f83f7044b994784216b6b696c7068adf.php(165): craft\helpers\Template::attribute() 
#8 /var/www/html/cms/vendor/twig/twig/src/Template.php(394): __TwigTemplate_9b840b5930aaed16d8eed50cbf1d7f63->doDisplay() 
#9 /var/www/html/cms/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling() 
#10 /var/www/html/cms/storage/runtime/compiled_templates/c7/c7d598d7a32bcd6068dacaacf8f04c64.php(79): Twig\Template->display() 
#11 /var/www/html/cms/vendor/twig/twig/src/Template.php(394): __TwigTemplate_f5ca602dcaf20990c83cc453ff385b6a->doDisplay() 
#12 /var/www/html/cms/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling() 
#13 /var/www/html/cms/storage/runtime/compiled_templates/3d/3db3b79563ff7091be6bc943c3cb83b4.php(75): Twig\Template->display() 
#14 /var/www/html/cms/vendor/twig/twig/src/Template.php(171): __TwigTemplate_9fad967727d10f964296f8c38292ee7e->block_content() 
#15 /var/www/html/cms/storage/runtime/compiled_templates/a0/a0a8176759d2d260a8624ccf469c4c14.php(172): Twig\Template->displayBlock() 
#16 /var/www/html/cms/vendor/twig/twig/src/Template.php(171): __TwigTemplate_c8fef1da9ad8ded19327ef4d05bb004f->block_htmlPage() 
#17 /var/www/html/cms/storage/runtime/compiled_templates/76/76a5e17d2b08b7cb69f25dddaf250e98.php(53): Twig\Template->displayBlock() 
#18 /var/www/html/cms/vendor/twig/twig/src/Template.php(394): __TwigTemplate_8c11e78c79e2c70925160a1713c7c0cc->doDisplay() 
#19 /var/www/html/cms/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling() 
#20 /var/www/html/cms/storage/runtime/compiled_templates/a0/a0a8176759d2d260a8624ccf469c4c14.php(55): Twig\Template->display() 
#21 /var/www/html/cms/vendor/twig/twig/src/Template.php(394): __TwigTemplate_c8fef1da9ad8ded19327ef4d05bb004f->doDisplay() 
#22 /var/www/html/cms/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling() 
#23 /var/www/html/cms/storage/runtime/compiled_templates/3d/3db3b79563ff7091be6bc943c3cb83b4.php(47): Twig\Template->display() 
#24 /var/www/html/cms/vendor/twig/twig/src/Template.php(394): __TwigTemplate_9fad967727d10f964296f8c38292ee7e->doDisplay() 
#25 /var/www/html/cms/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling() 
#26 /var/www/html/cms/storage/runtime/compiled_templates/98/988048fe18240f00ce5c4316e84d3829.php(43): Twig\Template->display() 
#27 /var/www/html/cms/vendor/twig/twig/src/Template.php(394): __TwigTemplate_05ceb513533627dd298b07658ce223c0->doDisplay() 
#28 /var/www/html/cms/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling() 
#29 /var/www/html/cms/vendor/twig/twig/src/Template.php(379): Twig\Template->display() 
#30 /var/www/html/cms/vendor/twig/twig/src/TemplateWrapper.php(40): Twig\Template->render() 
#31 /var/www/html/cms/vendor/twig/twig/src/Environment.php(277): Twig\TemplateWrapper->render() 
#32 /var/www/html/cms/vendor/craftcms/cms/src/web/View.php(451): Twig\Environment->render() 
#33 /var/www/html/cms/vendor/craftcms/cms/src/web/View.php(504): craft\web\View->renderTemplate() 
#34 /var/www/html/cms/vendor/craftcms/cms/src/web/TemplateResponseFormatter.php(56): craft\web\View->renderPageTemplate() 
#35 /var/www/html/cms/vendor/yiisoft/yii2/web/Response.php(1098): craft\web\TemplateResponseFormatter->format() 
#36 /var/www/html/cms/vendor/craftcms/cms/src/web/Response.php(286): yii\web\Response->prepare() 
#37 /var/www/html/cms/vendor/yiisoft/yii2/web/Response.php(339): craft\web\Response->prepare() 
#38 /var/www/html/cms/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send() 
#39 /var/www/html/cms/web/index.php(24): yii\base\Application->run() 
#40 {main} {"trace":[],"memory":65584152,"category":"craft\errors\ImageTransformException","timestamp":1686235472.860856,"exception":"[object] (craft\errors\ImageTransformException(code: 0): Failed to generate transform with id of 57113. at /var/www/html/cms/vendor/craftcms/cms/src/imagetransforms/ImageTransformer.php:481)"} []

Craft CMS version

"craftcms/cms": "4.3.6.1",

PHP version

php:8.1-fpm-alpine

Operating system and version

php:8.1-fpm-alpine

Database type and version

aurora

Image driver and version

No response

Installed plugins and versions

@i-just
Copy link
Contributor

i-just commented Jun 9, 2023

Hi, thanks for reaching out.

It looks like this transform is defined in a template. Image transforms defined in the Control Panel are referred to in the imagetransformindex table by their handle. Image transforms defined in the template are described by their characteristics (width, height, mode etc.). More info on defining transforms in the templates can be found here: https://craftcms.com/docs/4.x/image-transforms.html#defining-transforms-in-your-templates.

Additionally, you might not recognise those dimensions if you’re using srcset sizes (https://craftcms.com/docs/4.x/image-transforms.html#generating-srcset-sizes). For example, having this in your code: {{ asset.getImg({ width: 300, height: 300 }, ['1.5x', '2x', '3x']) }} would generate 4 transforms _300x300_..., _450x450_..., _600x600_... and _900x900_....

Based on the stack trace, it looks like the error is being thrown from here: https://github.com/craftcms/cms/blob/4.3.6.1/src/imagetransforms/ImageTransformer.php#L475-L484 - by the safety mechanism that ensures that we’re not trying to process a transform that’s being worked on (inProgress) at the same time.

The way I see it, you could try to remove just that one row, access the page this asset is used on and check the outcome - was the transform generated correctly, are there any new errors in the logs that could help us narrow it down, etc.? Alternatively, if you prefer not to touch the database yourself, you can clear the asset transform index cache (Control Panel > Utilities > Caches > Asset transform index) - this will remove all content of the imagetransformindex table.

@i-just i-just self-assigned this Jun 9, 2023
@joepagan
Copy link
Author

joepagan commented Sep 7, 2023

Thanks @i-just I can confirm there were several rows in the imagetransformindex table where the error field had a value of 1. I think this was where we attempted AVIF transforms on a server and it fell over, we generate transforms on page load so I guess there was no queue task/job that showed an error, but this row always remained. I feel like there must be a better way to manage that rather than deleting these rows manually, but thanks.

@joepagan joepagan closed this as completed Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants