Problem/Motivation
There is a code snippet from options.api.php file:
function hook_options_list_alter(array &$options, array $context) {
// Check if this is the field we want to change.
if ($context['fieldDefinition']->id() == 'field_option') {
// Change the label of the empty option.
$options['_none'] = t('== Empty ==');
}
}
This piece of code assumes that $context['fieldDefinition']->id() returns a field name, but it's not correct. See:

As we can see, id() method returns a full identifier, that contains entity type, bundle, and field name. getName() returns the expected value.
Proposed resolution
Replace $context['fieldDefinition']->id() with $context['fieldDefinition']->getName().
Comments
Comment #3
matroskeenComment #4
larowlanStraight forward fix, thanks
Comment #7
catchCommitted/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!