On my very basic Drupal installation (default theme, Croatian/Bosnian/Serbian languages, AddToAny and Social Media Links block extensions) after upgrading from 8.2.6 to 8.3.0-rc1 or rc2 I get:

Got error 'PHP message: Uncaught PHP Exception InvalidArgumentException: "Field is unknown." at /var/www/zakon.link/html/core/lib/Drupal/Core/Entity/ContentEntityBase.php line 509\n

upon accessing a static page. Downgrading to 8.2.7 fixes the problem. This is all that is printed in PHP-FPM log. Any other info I can provide?

CommentFileSizeAuthor
#17 Screenshot_20170407_115229.png32.25 KBpick_d
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

rivanvx created an issue. See original summary.

cilefen’s picture

Priority: Critical » Major

What do you mean by a "static page"?

Liam McDermott’s picture

I'm hitting this issue too when upgrading from 8.2.7 -> 8.3.0. Not sure what's meant by 'static page' in this context, in our case the error is occurring on the site front page, which is of the 'Basic page' content type (and also has some blocks on it).

cilefen’s picture

@Liam McDermott Have you got those same modules installed as the original reporter?

Liam McDermott’s picture

Status: Active » Closed (works as designed)

No, none of those are installed on the site in question. However, I fixed this issue by running drush updatedb, I'm assuming the cause of this is not running DB updates, so anyone else getting this error after upgrading should try running database updates.

I'm closing this for now, but I may be wrong so please re-open it if anyone is still experiencing this issue.

xjm’s picture

Priority: Major » Critical
Status: Closed (works as designed) » Active

Reopening this and bumping to critical since it was also reported in #2867253: Upgrade to 8.3.0: Call to a member function get() on array in CacheCollector.php . In multiple different issues, users have reported running database updates a number of times resolved their issues (in some cases with different fatals reported), so that is worth attempting if anyone else encounters this. Anyone encountering this should also ensure they are on Drush 8.1.10 before running updates since earlier versions of Drush also include bugs with update ordering.

xjm’s picture

Title: InvalidArgumentException "Field is unknown" when accessing a static page » InvalidArgumentException "Field is unknown"
xjm’s picture

@pick_d reported in #2867253: Upgrade to 8.3.0: Call to a member function get() on array in CacheCollector.php , when updating from 8.2.7 to 8.3.0:

I didn't have AdvAgg installed as far as I know. Here's the list of extensions:

drush config-get core.extension

module:
  amp: 0
  automated_cron: 0
  block: 0
  block_content: 0
  bootstrap_library: 0
  breakpoint: 0
  ckeditor: 0
  color: 0
  config: 0
  contact: 0
  contextual: 0
  ctools: 0
  datetime: 0
  dblog: 0
  dynamic_page_cache: 0
  editor: 0
  field: 0
  field_ui: 0
  file: 0
  filter: 0
  help: 0
  history: 0
  image: 0
  language: 0
  link: 0
  locale: 0
  menu_ui: 0
  node: 0
  options: 0
  page_cache: 0
  path: 0
  quickedit: 0
  rdf: 0
  redirect: 0
  respondjs: 0
  search: 0
  shortcut: 0
  system: 0
  taxonomy: 0
  text: 0
  token: 0
  toolbar: 0
  tour: 0
  update: 0
  user: 0
  views_ui: 0
  xmlsitemap: 0
  xmlsitemap_custom: 0
  xmlsitemap_engines: 0
  menu_link_content: 1
  pathauto: 1
  views: 10
  standard: 1000
theme:
  stable: 0
  classy: 0
  seven: 0
  amptheme: 0
  myamp: 0
  bootstrap: 0
  mybt: 0
_core:
  default_config_hash: m2GVq11UAOVuNgj8x0t5fMOPujpvQQ_zxLoaly1BMEU
langcode: ru
So… I'm wondering if #11 provided the right core.extension config dump? Is it up-to-date and from the correct site?

I will try to recheck information.

Below is info from correct site for sure, I restored the backup of 8.2.7 site and tried to upgrade multiple times with different ways (removing broken files and mysql and restoring from backup), but no luck.

$ drush config-get core.extension
module:
  amp: 0
  automated_cron: 0
  block: 0
  block_content: 0
  bootstrap_library: 0
  breakpoint: 0
  ckeditor: 0
  color: 0
  config: 0
  contact: 0
  contextual: 0
  ctools: 0
  datetime: 0
  dblog: 0
  dynamic_page_cache: 0
  editor: 0
  field: 0
  field_ui: 0
  file: 0
  filter: 0
  help: 0
  history: 0
  image: 0
  language: 0
  link: 0
  locale: 0
  menu_ui: 0
  node: 0
  options: 0
  page_cache: 0
  path: 0
  quickedit: 0
  rdf: 0
  redirect: 0
  respondjs: 0
  search: 0
  shortcut: 0
  system: 0
  taxonomy: 0
  text: 0
  token: 0
  toolbar: 0
  tour: 0
  update: 0
  user: 0
  views_ui: 0
  xmlsitemap: 0
  xmlsitemap_custom: 0
  xmlsitemap_engines: 0
  menu_link_content: 1
  pathauto: 1
  views: 10
  standard: 1000
theme:
  stable: 0
  classy: 0
  seven: 0
  amptheme: 0
  myamp: 0
  bootstrap: 0
  mybt: 0
_core:
  default_config_hash: m2GVq11UAOVuNgj8x0t5fMOPujpvQQ_zxLoaly1BMEU
langcode: ru

Those are installed modules inside appropriate directory:
ls modules/
amp bootstrap_library ctools pathauto redirect respondjs token xmlsitemap
(removed readme.txt of course from this list)

And here's the list of contrib modules I got with command
drush pm-list --type=Module --no-core --status=enabled

Package           Name                                      Version        
 Bootstrap         Bootstrap Library (bootstrap_library)     8.x-1.8        
 Chaos tool suite  Chaos tools (ctools)                      8.x-3.0-beta1  
 Other             Accelerated Mobile Pages (AMP) (amp)      8.x-1.0        
 Other             Pathauto (pathauto)                       8.x-1.0-rc1    
 Other             Redirect (redirect)                       8.x-1.0-alpha4 
 Other             Token (token)                             8.x-1.0-rc1    
 Responsive        Respond.js (respondjs)                    8.x-1.1        
 XML sitemap       XML sitemap (xmlsitemap)                  8.x-1.0-alpha2 
 XML sitemap       XML sitemap custom (xmlsitemap_custom)    8.x-1.0-alpha2 
 XML sitemap       XML sitemap engines (xmlsitemap_engines)  8.x-1.0-alpha2 

I've also tried it with nginx and apache, with drush 7 and drush 8 - that doesn't change much.

Okay, I uninstalled Pathauto and Token from existing config and tried to upgrade.
Got "unexpected error", when tried to proceed with "update.php"

Here's the log:

2017/04/07 00:24:32 [error] 21460#21460: *573823 FastCGI sent in stderr: "PHP message: Uncaught PHP Exception InvalidArgumentException: "Field  is unknown." at /home/u2868/domains/mydomainname.info/core/lib/Drupal/Core/Entity/ContentEntityBase.php line 509
PHP message: Error: Class 'Lullabot\AMP\AMP' not found in /home/u2868/domains/mydomainname.info/modules/amp/src/Service/AMPService.php on line 54 #0 /home/u2868/domains/mydomainname.info/modules/amp/src/Render/AmpHtmlResponseMarkupProcessor.php(76): Drupal\amp\Service\AMPService->createAMPConverter()
#1 /home/u2868/domains/mydomainname.info/core/lib/Drupal/Component/DependencyInjection/Container.php(276): Drupal\amp\Render\AmpHtmlResponseMarkupProcessor->__construct(Object(Drupal\amp\Service\AMPService), Object(Drupal\Core\Logger\LoggerChannel), Object(Drupal\Core\Config\ConfigFactory))
#2 /home/u2868/domains/mydomainname.info/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService(Array, 'html_response.a...')
#3 /home/u2868/domains/mydomainname.info/core/lib/Drupal/Component/DependencyInjection/Container.php(494): Drupal\Component\DependencyInjection\Container->get('html_response.a...', 1)
#4 /home/u2868/domains/mydomainname.info/core/lib/Drupal" while reading response header from upstream, client: 5.164.200.223, server: mydomainname.info, request: "GET /update.php/selection HTTP/2.0", upstream: "fastcgi://unix:/var/run/php5-mydomainname.info.sock:", host: "mydomainname.info", referrer: "https://mydomainname.info/update.php"
2017/04/07 00:24:38 [error] 21460#21460: *573823 FastCGI sent in stderr: "PHP message: Uncaught PHP Exception InvalidArgumentException: "Field  is unknown." at /home/u2868/domains/mydomainname.info/core/lib/Drupal/Core/Entity/ContentEntityBase.php line 509
PHP message: Error: Class 'Lullabot\AMP\AMP' not found in /home/u2868/domains/mydomainname.info/modules/amp/src/Service/AMPService.php on line 54 #0 /home/u2868/domains/mydomainname.info/modules/amp/src/Render/AmpHtmlResponseMarkupProcessor.php(76): Drupal\amp\Service\AMPService->createAMPConverter()
#1 /home/u2868/domains/mydomainname.info/core/lib/Drupal/Component/DependencyInjection/Container.php(276): Drupal\amp\Render\AmpHtmlResponseMarkupProcessor->__construct(Object(Drupal\amp\Service\AMPService), Object(Drupal\Core\Logger\LoggerChannel), Object(Drupal\Core\Config\ConfigFactory))
#2 /home/u2868/domains/mydomainname.info/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService(Array, 'html_response.a...')
#3 /home/u2868/domains/mydomainname.info/core/lib/Drupal/Component/DependencyInjection/Container.php(494): Drupal\Component\DependencyInjection\Container->get('html_response.a...', 1)
#4 /home/u2868/domains/mydomainname.info/core/lib/Drupal" while reading response header from upstream, client: 5.164.200.223, server: mydomainname.info, request: "GET /update.php/selection HTTP/2.0", upstream: "fastcgi://unix:/var/run/php5-mydomainname.info.sock:", host: "mydomainname.info", referrer: "https://mydomainname.info/update.php"

I replaced actual domain name with mydomainname to avoid being marked as spam.

Not sure I understand those logs correctly, but I will try to disable AMP and AMP theme and upgrade without it.

So restored my backup, removed module AMP only, then tried to upgrade when received:

"Unexpected error. Pls try again later" after proceeding update via /update.php

2017/04/07 00:38:49 [error] 21461#21461: *574320 FastCGI sent in stderr: "PHP message: Uncaught PHP Exception InvalidArgumentException: "Field  is unknown." at /home/u2868/domains/mydomainname.info/core/lib/Drupal/Core/Entity/ContentEntityBase.php line 509" while reading response header from upstream, client: 5.164.200.223, server: mydomainname.info, request: "GET /update.php/selection HTTP/2.0", upstream: "fastcgi://unix:/var/run/php5-mydomainname.info.sock:", host: "mydomainname.info", referrer: "https://mydomainname.info/update.php"

I even updated drush locally with composer require drush/drush and composer update to get drush 8.1.10 locally (not sure how that could help).
System drush is 8.0.2 though and I cannot update it.

But still - no luck.

Here's the related log.

[Fri Apr 07 03:54:26 2017] [error] [client 193.105.134.166] PHP Fatal error:  Class 'Lullabot\\AMP\\AMP' not found in /home/u5712/domains/mydomainname.info/modules/amp/src/Service/AMPService.php on line 54, referer: http://mydomainname.info/update.php/results
[Fri Apr 07 03:54:39 2017] [error] [client 193.105.134.166] PHP Fatal error:  Class 'Lullabot\\AMP\\AMP' not found in /home/u5712/domains/mydomainname.info/modules/amp/src/Service/AMPService.php on line 54, referer: http://mydomainname.info/update.php/results
[Fri Apr 07 03:54:45 2017] [error] [client 193.105.134.166] PHP Fatal error:  Class 'Lullabot\\AMP\\AMP' not found in /home/u5712/domains/mydomainname.info/modules/amp/src/Service/AMPService.php on line 54, referer: http://mydomainname.info/admin/config/development/performance
[Fri Apr 07 03:54:50 2017] [error] [client 193.105.134.166] PHP Fatal error:  Class 'Lullabot\\AMP\\AMP' not found in /home/u5712/domains/mydomainname.info/modules/amp/src/Service/AMPService.php on line 54, referer: http://mydomainname.info/admin/config/development/performance
[Fri Apr 07 03:55:36 2017] [error] [client 193.105.134.166] PHP Fatal error:  Class 'Lullabot\\AMP\\AMP' not found in /home/u5712/domains/mydomainname.info/modules/amp/src/Service/AMPService.php on line 54, referer: http://mydomainname.info/admin/config/development/performance
run database updates multiple times

that might be good idea, but how?

update.php breaks in the middle of process OR after first update and then I get empty web-pages (so I can't do anything with update.php) and drush is like:

$ drush updb
No database updates required
$ drush entup
No entity schema updates required                                                                                                                                                                                                                                                [success]
Cache rebuild complete.                                                                                                                                                                                                                                                          [ok]
Finished performing updates.

I've tried both commands many times and it doesn't look like they update databases at all.

Try running update.php through the UI,

I tried like 5-7 times with update.php and countless times with drush. Same result.

I've contacted hosting-provider and asked them about this issue and system-wide drush update, awaiting response now.

xjm’s picture

Is everyone getting this using a multilingual configuration? Or a language other than English?

xjm’s picture

Title: InvalidArgumentException "Field is unknown" » InvalidArgumentException "Field is unknown" in ContentEntityBase
xjm’s picture

Looked for other issues with this error in other situations to figure out if such an error could be caused by a problem with entity updates or data integrity, found:

xjm credited pick_d.

xjm’s picture

Also @pick_d, it looks like the last fatals are about AMP code being missing when that was uninstalled. I wonder if that is something else gone wrong.

alexpott’s picture

The worrying thing here is that we've somehow got to \Drupal\Core\Entity\ContentEntityBase::getTranslatedField() with no field name. That is very strange.

      $definition = $this->getFieldDefinition($name);
      if (!$definition) {
        throw new \InvalidArgumentException("Field $name is unknown.");
      }

So we don't even know which field is causing the problem.

alexpott’s picture

Backtraces here made me looked at the AMP module - I discovered #2867636: amp_update_8002() should be a post update about one of the updates that AMP has. Theoretically that might cause the field data to get out of sync. However only 1 person is confirmed to be or have used the AMP module.

alexpott’s picture

#2867636: amp_update_8002() should be a post update is possibly related. Not at all confirmed but calling \Drupal::entityDefinitionUpdateManager()->applyUpdates(); inside hook_update_N is not supported and could corrupt entity info.

pick_d’s picture

Also @pick_d, it looks like the last fatals are about AMP code being missing when that was uninstalled.

That's weird because last one was from fresh backup (I restored both mysql DB and files) and I haven't uninstalled AMP on this setup.
Also my "experiment" with uninstalling AMP before upgrade to 8.3.0 was made on another web-server, so the log related to "amp stuff not found" is totally strange to me.

I'll try to apply patch #3 from here: https://www.drupal.org/node/2867636
Let's see if that changes anything.

UPD: nope. didn't change anything for me.
I applied the patch by downloading into modules/amp/ with patch -p1 < 2867636-3.patch
Log is exactly the same with:
[Fri Apr 07 11:38:19 2017] [error] [client 193.105.134.166] PHP Fatal error: Class 'Lullabot\\AMP\\AMP' not found in /home/u5712/domains/mydomainname.info/modules/amp/src/Service/AMPService.php on line 54, referer: http://mydomainname/update.php/results

My site is using RU locale and language. Might be the case?
@alexpott noted ::getTranslatedField()
I changed system language via UI to English language and updated translations manually via UI.
It caused few updates including drupal core and amp translations (screenshot attached).
But in the end I got same result and same log as above.

pick_d’s picture

I tried to totally remove AMP on this setup.

Uninstalled via UI, removed modules/amp directory, update DB

And it worked even with drush 8.0.2.

Which means that my issue was related to some kind of error within AMP module.

alexpott’s picture

@pick_d well the error Class 'Lullabot\\AMP\\AMP' not found implies that the AMP library (which is required by the module) has not been found. Which means for whatever reason your autoloader can't load it. The mostly likely reason is that you don't have vendor/lullabot/amp and somehow you have removed the dependency before uninstalling the module.

EDIT: It is possible that you removed the dependency whilst following the update instructions since this dependency is not part of the core.

pick_d’s picture

The mostly likely reason is that you don't have vendor/lullabot/amp and somehow you have removed the dependency before uninstalling the module.

I checked now and it doesn't look like that:

ls backup-8.2.7/vendor/lullabot/amp/
amp-console composer.json LICENSE.txt phpunit.xml README.md sample-html src tests

ls live-site-8.3.0/vendor/lullabot/amp/
amp-console composer.json LICENSE.txt phpunit.xml README.md sample-html src tests
(AMP is reinstalled here after upgrading to 8.3.0)

catch’s picture

@Liam can you confirm you only got this due to not running updates at all? Or that you had to run updates twice?

alexpott’s picture

@pick_d then my other guess is that somehow vendor/composer/autoload_psr4.php got replaced with the one from the core which doesn't have the map for lullabot\amp classes.

pick_d’s picture

@alexpott
well, probably.

I don't really understand things in Drupal, just trying to maintain my websites, but I'll try to provide all info that could help to catch and/or fix those nasty bugs.

alexpott’s picture

@pick_d your reports of the issues you've faced are really appreciated. Thank you.

alexpott’s picture

Status: Active » Postponed (maintainer needs more info)

Discussed with @catch, @Cottser, @effulgentsia, and @xjm. We really need more information to determine the cause of the exception. Maybe we should create an issue add some instrumentation or an earlier exception somewhere to make the error easier to work out.

@pick_d did you manage to resolve your AMP module issues - there are a number or bugs about re-installing the module - see #2867733: Make the Amp module re-installable - these have been fixed recently.

Berdir’s picture

Component: base system » entity system

The exception message is actually Field X is unknown as pointed out in #14 alreada and it is likely that the reports are all kinds of different problems but I don't think they are core problems. Basically, someone is calling $entity->get(''), possibly due to changed configuration, missing update functions or all kinds of other issues.

I don't think this is something that can be "solved" in core and is not a critical bug *in core* (or at least not in the entity system), but leaving at that for now.

As I think has been pointed out before, the best you can do is enable verbose error logging, check the first module that shows up in the stack trace (Drupal\x\... where X is not Core and report a bug there). And if that module happens to be a core module, then update this issue.

SchwebDesign’s picture

This happened to us as well. In our case, this was caused simply by neglecting to run update.php. We had to manually navigate to /update.php, run the updates, and all was well.

guzabi’s picture

I'm new to Drupal and I can't believe my eyes : critical bug, blocking, reproductible, recurrent acrosse 8.3.x versions, open for over a month and not even attributed to someone? I'm sorry but this can't happen. I can't solve the problem by editing the fields in the content type because there also is an exception when editing fields for a content type :

Uncaught PHP Exception Drupal\Core\Entity\Exception\UnsupportedEntityTypeDefinitionException: "The entity type node does not have a "xxx" entity key." at /core/lib/Drupal/Core/Entity/EntityPublishedTrait.php line 32

After doing that, even the "manage fields" page throws the same exception.

I'l try again using Drupal when it works.

alexpott’s picture

@guzabi do you have outstanding updates? @SchwebDesign solved it by going to EXAMPLE.COM/update.php and running the updates. The error you are getting is because node_update_8301() has not run.

catch’s picture

@guzabi

not even attributed to someone?

In general core issues don't get assigned to a single individual, because that discourages other people from working on it. This issue has several regular Drupal core maintainers contributing to it including four core committers, several of whom have asked people running into the problem to provide more information. If you're able to answer @alexpott's question in #29 that would help to resolve this issue quicker.

alexpott’s picture

Here's idea for helping users find there way to update.php #2877643: Redirect to update.php if \Drupal::version() different from container version

drzraf’s picture

Same error starting migration with 8.3.x

[...]
error: Missing bundle for entity type taxonomy_term (/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:83)
error: Missing bundle for entity type taxonomy_term (/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:83)
error: Missing bundle for entity type taxonomy_term (/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:83)
error: Missing bundle for entity type taxonomy_term (/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:83)
error: Missing bundle for entity type taxonomy_term (/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:83)
error: Missing bundle for entity type taxonomy_term (/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:83)
Upgrading d6_node_revision:story
Upgrading upgrade_d6_vocabulary_field
Upgrading d6_node_revision:webform
[...]
Upgrading upgrade_d6_vocabulary_field_instance
Upgrading d6_taxonomy_vocabulary
Upgrading upgrade_d6_vocabulary_entity_display
Upgrading d6_vocabulary_field
Upgrading upgrade_d6_vocabulary_entity_form_display
Upgrading d6_vocabulary_field_instance
Upgrading upgrade_d6_term_node_10
error: InvalidArgumentException: Field region is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 509 of /core/lib/Drupal/Core/Entity/ContentEntityBase.php). 
error: Field region is unknown. (/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:777)
error: InvalidArgumentException: Field region is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 509 of /core/lib/Drupal/Core/Entity/ContentEntityBase.php).
[...] ... thousands of them
error: Field region is unknown. (/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:777)
Upgrading d6_vocabulary_entity_form_display
Upgrading upgrade_d6_term_node_11
InvalidArgumentException: Field region is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 509 of [...]
drzraf’s picture

Although I got this message printed thousands of times, I can provide 0 information to this "need info" issue.
I tragically misses a function stack trace (+ arguments). At least add $langcode to the message, maybe log somewhere $this->fields and $definition or use the migrate-message table to keep track of the errors ?

drzraf’s picture

Got it.
In my case it has to do with one these two tables: path_redirect or url_alias
They contain entries like :
INSERT INTO `path_redirect` VALUES (1305,'categories-faq/FOO/feed','taxonomy/term/483/0/feed','','','',301,1470068425);
or
INSERT INTO `url_alias` VALUES (14617,'taxonomy/term/587','categories-faq/BAR','');

where "categories-faq" is not a known content type or anything like that (no other occurence of the "categories.*faq" pattern in the DB dump)

That is sufficient to trigger:

InvalidArgumentException: Field categories_faq is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 509 of /core/lib/Drupal/Core/Entity/ContentEntityBase.php).
Field categories_faq is unknown. (/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:777

Which bug is it a duplicate for?

Berdir’s picture

Your errors are different (you actually have a field name that does not exist) and you have a lot of errors above that, so those are follow-up errors after it likely failed to create taxonomy bundles, fields and so on earlier. If this is the default migration then I would suggest you open an issue about that. If you can, provide the source data so that it can be reproduced, I suspect it will be hard to do that without any data. And you should try to restart the whole migration process on a clean site and provide the first errors you get, because that's likely where it started to go wrong.

BEGRAFX’s picture

I encountered this error message (Drupal 8.3.2) I don't have any of the modules that were mentioned at the top of the thread, but, someone above suggested running Drush Update. I didn't have Drush on this site, but just running UPDATE.PHP seems to have resolved the issue.

cilefen’s picture

Executing update.php is a step in the update instructions.

mrweiner’s picture

I can confirm that in my case, I was able to fix my problem by updating to the latest version of the AMP module and running drush updatedb since the update page was inaccessible. If you are using composer.json to manage your modules, make sure you change the minimum version to dev.

BEGRAFX’s picture

Cilefen,

I'm not arguing that point. I'm simply saying, I manually ran UPDATE.PHP and it appears to have resolved the problem.

netnerd85’s picture

Any call to a field on a node entity such as $e->get('body') should be wrap in if($e->hasField('body'))

if($e->hasField('body')) {
  $body = $e->get('body') ;
}

The other stated solutions did not work for me.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

skorasaurus’s picture

I do not have any other languages besides English installed and hit this error when I upgraded my site from 8.2.8 to 8.3.6. I do not have AMP installed; here's a list of my installed modules.

I was able to fix this by visiting mysite/update.php