Just identified an issue in realname module, but it was very difficult to identify the root cause. I only received this unhelpful exception. But there was no reference to what is wrong and after some debugging I found it could be every composer.json in my folder and all the many subfolders.

> Drupal\composer_manager\Composer\Command::update
Script Drupal\composer_manager\Composer\Command::update handling the drupal-update event terminated with an exception


  [UnexpectedValueException]
  Could not decode JSON: Syntax error

I added some print_r() to src/JSONFile.php to find the root cause and found it than.

I will attach a patch to improve logging output.

Comments

hass created an issue. See original summary.

hass’s picture

Status: Active » Needs review
StatusFileSize
new739 bytes

This patch improves the error message and is fully tested. Example output:

composer drupal-update
> Drupal\composer_manager\Composer\Command::update
Script Drupal\composer_manager\Composer\Command::update handling the drupal-update event terminated with an exception


  [UnexpectedValueException]
  Could not decode JSON file "D:\InetPub\wwwroot\drupal8/modules/realname/composer.json". Error message: Syntax error


drupal-update [--dev] [--no-dev] [--] [<args>]...

Testing the issue is quite simple. Just open a composer.json of any module that has "require" and remove the doubles quotes from the project "drupal/token".

"require": {
  drupal/token: "dev"
}

  • bojanz committed 0a8d0b5 on 8.x-1.x authored by hass
    Issue #2735973 by hass: Increase error details on invalid JSON
    
bojanz’s picture

Status: Needs review » Fixed

Committed, thanks.

hass’s picture

As you deprecated the 8.x - should this backported?

Status: Fixed » Closed (fixed)

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