CustomBlock has
public function bundle() {
return $this->type->value;
}
This relies on EntityNG magic whizbang.
Depending on where in the callstack this gets called (#1969728: Implement Field API "field types" as TypedData Plugins needs to call $entity->bundle() while the FieldItem object for 'block_body' is being created, during entity_create()), it seems everything might not be properly initialized, and the above returns NULL.
CustomBlock extends EntityNG, and EntityNG just returns $this->bundle, which just works.
Not sure why CustomBlock tries to do differently, but it doesn't seem needed :-)
Same thing for id().