PECL YAML errors at valid YAML file which only contains comments

Created on 29 September 2018, about 6 years ago
Updated 5 July 2024, 6 months ago

Problem/Motivation

What are the steps required to reproduce the bug?
Do something that requires Drupal to process a YAML file which only contains comments.
In my case it was installing a theme which has multiple YAML files, one of which holds a commented out example configuration.

Do so in an environment which has PECL YAML installed, otherwise Drupal will use the Symfony YAML component which appears to be more standards compliant for this aspect.

What behavior were you expecting?
No errors, because YAML files with only comments are valid. See http://yaml.org/spec/current.html#id2527268

What happened instead?
A PHP warning was thrown.

Drupal\Component\Serialization\Exception\InvalidDataTypeException: yaml_parse(): end of stream reached without finding document 0 in            [error]
/var/www/docroot/core/lib/Drupal/Component/Serialization/YamlPecl.php:72
Stack trace:
#0 [internal function]: Drupal\Component\Serialization\YamlPecl::errorHandler(2, 'yaml_parse(): e...', '/var/www/docro...', 54, Array)
#1 /var/www/docroot/core/lib/Drupal/Component/Serialization/YamlPecl.php(54): yaml_parse('# layout_name_g...', 0, 0, Array)

Proposed resolution

Catch the specific error message and treat it just like we already treated empty YAML files since #1920902: Add a Drupal Yaml wrapper so we can default to PECL Yaml component if it is available β†’

Remaining tasks

Patch review.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Closed: outdated

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated 3 minutes ago

Created by

πŸ‡§πŸ‡ͺBelgium PieterDC Ghent

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    This will need a test case to show the issue.

  • Status changed to Closed: outdated 6 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    This was a bugsmash triage target today. Both chx and mstrlen recommend that this is closed as outdated.

Production build 0.71.5 2024