Empty node workflow state on node after programmatically saving I have saved a node programmatically, in the following way:

  $node_storage = \Drupal::entityManager()-&gt;getStorage('node');
  foreach ($entity_ids as $id) {
    $node = $node_storage-&gt;load($id);
    if (!$node) {
      continue;
    }
    $node-&gt;set('field_tags', $new_tid);
    $node-&gt;save();


After saving the node I am trying to edit it and I am getting the follow error upon submit.

InvalidArgumentException: The state '' does not exist in workflow 'draft' in Drupal\workflows\Entity\Workflow-&gt;getState()


I believe that this means that my node has no state.

How could I set the node's state?
There's a code for creating a node and indicating its status, maybe it would help:

&lt;?php
// add node properties
$newNode = (object) NULL;
$newNode-&gt;type = '{NODE_TYPE}';
$newNode-&gt;title = '{NODE_TITLE}'
$newNode-&gt;uid = {USER_ID};
$newNode-&gt;created = strtotime("now");
$newNode-&gt;changed = strtotime("now");
$newNode-&gt;status = 1;
$newNode-&gt;comment = 0;
$newNode-&gt;promote = 0;
$newNode-&gt;moderate = 0;
$newNode-&gt;sticky = 0;

// add CCK field data
$newNode-&gt;field_{YOUR_CUSTOM_FIELD_1}[0]['value'] = '{DATA_1}';
$newNode-&gt;field_{YOUR_CUSTOM_FIELD_2}[0]['value'] = '{DATA_2}';

// save node
node_save($newNode);
?&gt;