The code throwing the exception was
var listViewWebPart = new ListViewWebPart
{
ListId = list.ID,
ChromeType = PartChromeType.None,
ViewGuid = list.Views[Constants.ViewNames.DocumentLibraryAllDocumentSets].ID.ToString("B").ToUpper()
};
webPartManager.AddWebPart(listViewWebPart, "Top", 1);
The solution was to change ListViewWebPart to XsltListViewWebPart. Once I did that the problem went away.