CSS files are found in node_modules and other third party directories

Created on 2 February 2023, almost 2 years ago
Updated 6 March 2024, 10 months ago

Problem/Motivation

When I attempt to scan a module with a node_modules that includes the normalize.css package the scan completes and reports 1 problem but it's just a stack trace and nothing was actually scan.

Here's the last few bits from the giant call stack:

Notice: file_get_contents(): Read of 8192 bytes failed with errno=21 Is a directory in /app/docroot/modules/contrib/upgrade_status/src/CSSDeprecationAnalyzer.php on line 29
    Call Stack:
       [...]
        2.3305 6890880 16. call_user_func_array:{/app/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123}($callback = [0 => class Drupal\upgrade_status\Controller\ScanResultController { protected $entityTypeManager = NULL; protected $entityFormBuilder = NULL; protected $languageManager = NULL; protected $configFactory = NULL; protected $keyValue = NULL; protected $currentUser = NULL; protected $stateService = NULL; protected $moduleHandler = NULL; protected $formBuilder = NULL; protected $loggerFactory = NULL; protected $messenger = NULL; protected $redirectDestination = NULL; protected $stringTranslation = NULL; protected $resultFormatter = class Drupal\upgrade_status\ScanResultFormatter { ... }; protected $projectCollector = class Drupal\upgrade_status\ProjectCollector { ... }; protected $renderer = class Drupal\Core\Render\Renderer { ... } }, 1 => 'analyze'], $args = [0 => 'custom_theme']) /app/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123
        2.3305 6890952 17. Drupal\upgrade_status\Controller\ScanResultController->analyze($project_machine_name = 'custom_theme') /app/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123
        2.8117 9084784 18. Drupal\upgrade_status\DeprecationAnalyzer->analyze($extension = class Drupal\Core\Extension\Extension { protected $type = 'theme'; protected $pathname = 'themes/custom/custom_theme/custom_theme.info.yml'; protected $filename = 'custom_theme.theme'; protected $splFileInfo = NULL; protected $root = '/app/docroot'; public $subpath = 'themes/custom/custom_theme'; public $origin = ''; public $info = ['name' => 'Custom Theme', 'type' => 'theme', 'description' => 'custom_theme.org website theme.', 'base theme' => 'stable', 'core_version_requirement' => '^9 || ^10', 'libraries' => [...], 'ckeditor_stylesheets' => [...], 'regions' => [...], 'logo' => 'images/logo.svg', 'components' => [...], 'core_incompatible' => FALSE, 'lifecycle' => 'stable', 'mtime' => 1675372635, 'engine' => 'twig', 'features' => [...], 'screenshot' => 'themes/custom/custom_theme/screenshot.png', 'version' => NULL, 'php' => '7.3.0', 'libraries_extend' => [...], 'libraries_override' => [...], 'dependencies' => [...], 'regions_hidden' => [...], 'upgrade_status_type' => 'custom', 'upgrade_status_next_major_compatible' => TRUE, 'project' => 'custom_theme', 'upgrade_status_next' => 'scan']; public $owner = 'core/themes/engines/twig/twig.engine'; public $prefix = 'twig'; public $status = 1; public $required_by = []; public $requires = ['stable' => class Drupal\Core\Extension\Dependency { ... }]; public $sort = -3; public $base_themes = ['stable' => 'Stable']; public $module_dependencies = [] }, $options = ???) /app/docroot/modules/contrib/upgrade_status/src/Controller/ScanResultController.php:138
        80.7649 15888072 19. Drupal\upgrade_status\CSSDeprecationAnalyzer->analyze($extension = class Drupal\Core\Extension\Extension { protected $type = 'theme'; protected $pathname = 'themes/custom/custom_theme/custom_theme.info.yml'; protected $filename = 'custom_theme.theme'; protected $splFileInfo = NULL; protected $root = '/app/docroot'; public $subpath = 'themes/custom/custom_theme'; public $origin = ''; public $info = ['name' => 'Custom Theme', 'type' => 'theme', 'description' => 'custom_theme.org website theme.', 'base theme' => 'stable', 'core_version_requirement' => '^9 || ^10', 'libraries' => [...], 'ckeditor_stylesheets' => [...], 'regions' => [...], 'logo' => 'images/logo.svg', 'components' => [...], 'core_incompatible' => FALSE, 'lifecycle' => 'stable', 'mtime' => 1675372635, 'engine' => 'twig', 'features' => [...], 'screenshot' => 'themes/custom/custom_theme/screenshot.png', 'version' => NULL, 'php' => '7.3.0', 'libraries_extend' => [...], 'libraries_override' => [...], 'dependencies' => [...], 'regions_hidden' => [...], 'upgrade_status_type' => 'custom', 'upgrade_status_next_major_compatible' => TRUE, 'project' => 'custom_theme', 'upgrade_status_next' => 'scan']; public $owner = 'core/themes/engines/twig/twig.engine'; public $prefix = 'twig'; public $status = 1; public $required_by = []; public $requires = ['stable' => class Drupal\Core\Extension\Dependency { ... }]; public $sort = -3; public $base_themes = ['stable' => 'Stable']; public $module_dependencies = [] }) /app/docroot/modules/contrib/upgrade_status/src/DeprecationAnalyzer.php:419
        82.6766 16361552 20. file_get_contents($filename = '/app/docroot/themes/custom/custom_theme/node_modules/normalize.css') /app/docroot/modules/contrib/upgrade_status/src/CSSDeprecationAnalyzer.php:29 {"message":"Scanned custom_theme"}

I'm able to work around the issue by temporarily renaming the normalize.css directory to something without the .css suffix.

Steps to reproduce

  1. Run npm install normalize.css in a theme folder.
  2. Attempt to scan the theme.

Proposed resolution

Prevent the scanner from evaluating files in node_modules? #3162997: Exclude node_modules from scan is somewhat related but this appears to be a different (and, indeed, the files in node_modules do not get reported on when i work around the issue).

Remaining tasks

Determine how to prevent this issue and create a patch.

🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇺🇸United States wells Seattle, WA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024