Add better error handling for ConfigSnapshotServiceProvider::register

Created on 13 September 2024, 7 months ago
Updated 18 September 2024, 7 months ago

Problem/Motivation

I see errors like:

 [warning] Trying to access array offset on false ConfigSnapshotServiceProvider.php:30
 [warning] Trying to access array offset on false ConfigSnapshotServiceProvider.php:30
 [warning] Trying to access array offset on false ConfigSnapshotServiceProvider.php:30
 [warning] Trying to access array offset on false ConfigSnapshotServiceProvider.php:31
 [warning] Trying to access array offset on false ConfigSnapshotServiceProvider.php:32
 [warning] Trying to access array offset on false ConfigSnapshotServiceProvider.php:33

Which isn't very helpful.

Steps to reproduce

Add messed up config to site
clear cache

Proposed resolution

Add better messaging for the error that occurs.

Remaining tasks

User interface changes

API changes

N/A

Data model changes

✨ Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ

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

Merge Requests

Comments & Activities

  • Issue created by @trackleft2
  • Pipeline finished with Success
    7 months ago
    Total: 163s
    #282723
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States joegraduate Arizona, USA
  • Status changed to RTBC 7 months ago
  • Thanks for working on this @trackleft2 !
    Tested out a few aspects of this:

    Verified that services are still being registered:

    $ drush devel:services
    ...
    - config_snapshot.config_sync.module.pathauto
    - config_snapshot.config_sync.module.redirect
    - config_snapshot.config_sync.module.search
    - config_snapshot.config_sync.module.shortcut
    ...
    

    Verified that errors are logged if unhandled exceptions occur elsewhere in provisioning the storage:

    Error initializing config storage: Failed to retrieve config storage.
    (And - separate error forced):
    Error initializing config storage: An unrelated error somewhere else occurred.
    

    Verified that errors are logged in the case of any of snapshotSet, extensionType, and extensionName being absent from malformed snapshots (in separate cases):

    Error processing config ID config_snapshot.snapshot..module.search: Invalid snapshot data for config ID config_snapshot.snapshot..module.search
    Error processing config ID config_snapshot.snapshot.config_sync..search: Invalid snapshot data for config ID config_snapshot.snapshot.config_sync..search
    Error processing config ID config_snapshot.snapshot.config_sync.module.: Invalid snapshot data for config ID config_snapshot.snapshot.config_sync.module.
    

    The only thing I noted was that the PHP error_log is used, rather than the Drupal log. But given that this is the service discovery phase, I'm not sure if using the Drupal log channel would even make sense. Perhaps that's why you selected the PHP error log to begin with?

  • Status changed to Fixed 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States joegraduate Arizona, USA

    Thanks all!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024