Better them checking if `$action` and `$type` are set, just use a bit later when we are sure that the processing was a success