Problem/Motivation
The error messages, one in particular, generated in Entity/FieldConfig.php are unintelligible.
Example:
The following error was generated on a configuration import:
"Attempt to create a field body that does not exist on entity type node."
I had a quick chat with @larowlan in slack #australia-nz and he suggests:
In this specific case I think you're missing field.storage.node.body and it is trying to create field.field.node.(something).body
If that's correct then that could help us come up with a clearer error message.
I wasn't able to deduce for myself what the error message was saying, was it a field called body or the body of a field, "attempt to create field body that does not exist", the opposite sounds more like an error scenario.
If "field body" is a standard term in drupal, I'm not aware of it (which could be me), though googling "drupal field body" returns results relating to the "body field".
And is the error that it 'attempted' to create something that does not exist, or is the error that something happened during the attempt.
I just don't know, and don't feel comfortable speculating on what an error message is trying to convey.
So, as you can see, at least for me this error message is very difficult to comprehend.
In case someone happens to search that error and land on this page, in my case the error occured during a configuration import on a fresh site install via drush cim. Simply running drush cim resolved the error in my case.
Proposed resolution
Formulate more intelligle error messages so as to improve comprehension when they are encounted.
There is a simlar issue open for drupal 7 here: https://www.drupal.org/project/drupal/issues/2077163
Issue fork drupal-3213023
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
cilefen commentedFor an issue to be novice there must be no ambiguity about how to proceed.
Comment #4
thursday_bw commentedComment #5
thursday_bw commentedOH. I didn't send my comment when I set this to needs review.
I have opened the merge request with changes to the error message in question, along with a minor change to an adjacent error for consistency.
The error in question is more concise and less prone to misinterpretation now.
Comment #7
joachim commentedDefinitely an improvement in clarity!
RTBC.
Comment #8
catchCommitted/pushed to 10.0.x and cherry-picked to 9.4.x, thanks!
Not backporting to 9.3.x because we have in the past seen people rely on exception message text in tests and similar.
Comment #11
catch