check if publish have valid type to prevent segfault