spatie / statamic-responsive-images

Responsive images for Statamic 3
MIT License
99 stars 29 forks source link

Internal Server Error When Querying SVG Image in GraphQL #245

Open emran-alhaddad opened 1 month ago

emran-alhaddad commented 1 month ago

Bug description

An internal server error occurs when executing a GraphQL query to retrieve data for a specific page. The error is related to the image validation process for an SVG image. The error is traced back to the Statamic\Imaging\ImageGenerator::validateImage() function.

How to reproduce

GraphQL Query:

query Page { entry(collection: "pages", site: "english", slug: "about-us") { ... on Entry_Pages_Default { title slug url website_components { ... on Set_WebsiteComponents_TopBanner { type banner_link_title banner_link_is_external banner_link_url banner_text_title banner_text_description banner_media_image { responsive { label asset { permalink url } } } } ... on Set_WebsiteComponents_AboutCompanySection { type about_company_link_is_external about_company_link_title about_company_link_url about_company_text_description about_company_text_title } ... on Set_WebsiteComponents_CompanyMessage { our_message_title our_message_description id type our_message_image { responsive { label asset { permalink url } } } } ... on Set_WebsiteComponents_CompanyVision { our_message_title our_message_description id type our_message_image { responsive { label asset { permalink url } } } } ... on Set_WebsiteComponents_CompanyGoalsSection { our_goals_title all_goals { ... on Set_WebsiteComponents_AllGoals_NewGoal { goal_title goal_description id type goal_image { responsive { label minWidth widthUnit ratio placeholder } } } } id type } } seo_title seo_keywords seo_image { url permalink } seo_description } } }

  1. Execute the provided GraphQL query to fetch the data for the specified page.
  2. Observe the response and note the internal server error.
  3. Review the debug message indicating an issue with the SVG image validation.

Error Details:

Debug Message: Image [uploads/pages/about-us/value-1.svg] does not actually appear to be a valid image. Message: Internal server error Error Category: Internal

Logs

- Statamic\\Imaging\\ImageGenerator::validateImage() at /vendor/statamic/cms/src/Imaging/ImageGenerator.php:255
- Statamic\\Imaging\\ImageGenerator::generate() at /vendor/statamic/cms/src/Imaging/ImageGenerator.php:167
- Statamic\\Imaging\\ImageGenerator::doGenerateByAsset() at /vendor/statamic/cms/src/Imaging/ImageGenerator.php:150
- Illuminate\\Cache\\Repository::rememberForever() at /vendor/laravel/framework/src/Illuminate/Cache/Repository.php:437
- Statamic\\Imaging\\ImageGenerator::generateByAsset() at /vendor/statamic/cms/src/Imaging/ImageGenerator.php:148
- Spatie\\ResponsiveImages\\Breakpoint::Spatie\\ResponsiveImages\\{closure}() at /vendor/spatie/statamic-responsive-images/src/Breakpoint.php:268
- Spatie\\Blink\\Blink::once() at /vendor/spatie/blink/src/Blink.php:306
- Statamic\\Support\\Blink::__call() at /vendor/statamic/cms/src/Support/Blink.php:18
- Illuminate\\Support\\Facades\\Facade::__callStatic() at /vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:355
- Spatie\\ResponsiveImages\\Breakpoint::placeholder() at /vendor/spatie/statamic-responsive-images/src/Breakpoint.php:255
- Spatie\\ResponsiveImages\\Breakpoint::placeholderSrc() at /vendor/spatie/statamic-responsive-images/src/Breakpoint.php:289
- Spatie\\ResponsiveImages\\Source::Spatie\\ResponsiveImages\\{closure}() at /vendor/spatie/statamic-responsive-images/src/Source.php:69
- Illuminate\\Support\\Collection::when() at /vendor/laravel/framework/src/Illuminate/Conditionable/Traits/Conditionable.php:34
- Spatie\\ResponsiveImages\\Source::getSrcSet() at /vendor/spatie/statamic-responsive-images/src/Source.php:68
- Spatie\\ResponsiveImages\\Source::toArray() at /vendor/spatie/statamic-responsive-images/src/Source.php:134
- Spatie\\ResponsiveImages\\Breakpoint::toGql() at /vendor/spatie/statamic-responsive-images/src/Source.php:123
- Spatie\\ResponsiveImages\\Breakpoint::Spatie\\ResponsiveImages\\{closure}() at /vendor/spatie/statamic-responsive-images/src/Breakpoint.php:232
- array_map() at /vendor/laravel/framework/src/Illuminate/Collections/Arr.php:600
- Illuminate\\Support\\Arr::map() at /vendor/laravel/framework/src/Illuminate/Collections/Collection.php:777
- Illuminate\\Support\\Collection::map() at /vendor/spatie/statamic-responsive-images/src/Breakpoint.php:231
- Spatie\\ResponsiveImages\\GraphQL\\ResponsiveField::Spatie\\ResponsiveImages\\GraphQL\\{closure}() at /vendor/spatie/statamic-responsive-images/src/GraphQL/ResponsiveField.php:49
- array_map() at /vendor/laravel/framework/src/Illuminate/Collections/Arr.php:600
- Illuminate\\Support\\Arr::map() at /vendor/laravel/framework/src/Illuminate/Collections/Collection.php:777
- Illuminate\\Support\\Collection::map() at /vendor/spatie/statamic-responsive-images/src/GraphQL/ResponsiveField.php:48
- Rebing\\GraphQL\\Support\\Field::Rebing\\GraphQL\\Support\\{closure}() at /vendor/rebing/graphql-laravel/src/Support/Field.php:251
- Rebing\\GraphQL\\Support\\Field::Rebing\\GraphQL\\Support\\{closure}() at /vendor/rebing/graphql-laravel/src/Support/Field.php:164
- Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}() at /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:144
- Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}() at /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:119
- Rebing\\GraphQL\\Support\\Field::Rebing\\GraphQL\\Support\\{closure}() at /vendor/rebing/graphql-laravel/src/Support/Field.php:163
- GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError() at /vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:623

Environment

php please support:details

Environment
Application Name: Alreef
Laravel Version: 10.48.10
PHP Version: 8.3.7
Composer Version: 2.7.6
Environment: local
Debug Mode: ENABLED
URL: alreef-cms.brackets-tech.com.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 4
Antlers: runtime
Sites: 2 (English, عربي)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.58.2 PRO

Statamic Addons
spatie/statamic-responsive-images: 4.1.1
statamic/eloquent-driver: 3.4.1
swiftmade/statamic-clear-assets: 2.0.1
teamnovu/statamic-unused-assets: 2.0.2

Statamic Eloquent Driver
Asset Containers: eloquent
Assets: eloquent
Blueprints: eloquent
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: eloquent
Taxonomies: eloquent
Terms: eloquent

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

regex (default)

Additional details

No response