This is the issue...hard to find!
https://www.sharepointblogs.be/blogs/vandest/archive/2011/10/19/sharepoint-default-library-content-type-is-folder.aspx
Must still be using 10yr old code 🙂
Steven Van de Craen's Blog - SharePoint - Default Library Content Type is Folder
Ever enabled Content Types on a library, removed the default “Document” Content Type and then added your own document Content Type ? If you do it in that order it will set “Folder” as the Content Type for uploaded files.
www.sharepointblogs.be