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

Command icon 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

cilefen’s picture

Title: Improve the intellibility of error messages in Entity/FieldConfig.php » Improve the intelligibility of error messages in Entity/FieldConfig.php
Issue tags: -Novice

For an issue to be novice there must be no ambiguity about how to proceed.

thursday_bw’s picture

Issue summary: View changes
Status: Active » Needs review
thursday_bw’s picture

OH. 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.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

joachim’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +DX (Developer Experience)

Definitely an improvement in clarity!

RTBC.

catch’s picture

Version: 9.2.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/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.

  • catch committed f1f7fb4 on 10.0.x
    Issue #3213023 by thursday_bw: Improve the intelligibility of error...

  • catch committed f8d5ced on 9.4.x
    Issue #3213023 by thursday_bw: Improve the intelligibility of error...
catch’s picture

Status: Fixed » Closed (fixed)

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