[OnePlus 5 Questions & Answers] mabz2k:
I've had a similar problem and I thought I broke my phone, got pretty scared can't buy a new phone but need a newer android for my apps to work.

I came from freedom OS on android 7 so I never had the project treble on my phone and tried to flash new factory images, as a result, no newer TWRP recovery worked and I was unable to boot into anything other than the bootloader. I had the same error with Error 7, from what I can understand this is from a screwed up or non-existing "vendor" partition which says stuff like "this is a OnePlus 5" for newer factory images to install (factory image told me I didn't have a OP5), this never existed in android 7 or OOS 4.X.X. ScRuFFy7 is correct, the vender partition was created in OOS 5.1.4 (or OTA 037) and only when android is booting up, this took like 10 mins on mine. Once this vendor partition is correctly created you can flash newer TWRP recovery (I flashed 3.4.0) and newer factory images, like OOS 9.0.11 then to version 10. The built-in updater and stock recovery can update to the newer versions with the flashable zip files. For whatever reason OnePlus don't size the partitions in their zips so they make small changes from one version to the next so skipping specfic versions throws up errors in the future.

Screw it, I should document what I did in case I mess up my phone in the future and maybe be helpful to someone else in need, especially in this messed up and depressing time of the plague. But anyway this is what I did to get my phone back, I should point out I have no idea what I'm doing. Meaning I'm a N00b.

NOTE: this process Wipes all the data from the phone, so I hope you have backups right now.

Will need ADB, you can install This on windows, it's super easy and works thanks to mauronofrio. You can get the all in one tool too from here it's pretty handy and can format and decrypt from the bootloader, from mauronofrio? I think? This guy is pretty good. I got all old firmware from Here thanks to Some_Random_Username for the life line since OnePlus won't provide the old Zips anymore.

1) Boot to TWRP recovery if you have it installed (VOL DOWN + POWER). If not Boot to Bootloader (VOL UP + POWER) and flash TWRP Recovery. You can use TWRP 3.1.1 This one works on OOS 4.X firmware without giving me a Black Screen.

1a) To Flash the Recovery you can use the all in one tool to flash it or open up command prompt and use the Fastboot Flash [insert recovery file name here .img] command to flash it, you can find the FastBoot Flashing Method in the middle of this page for instructions.

2) Format Data. The Format Data button in TWRP recovery not the swipe to factory reset, because we're going back to scratch.

3) Flash OTA_006 (OOS 4.5.2) original firmware from the link above (says ota_006 in the middle of the loong file name)

4) Boot into android and use System Update in settings and stock recovery it just flashed to flash OTA_020 (OOS 4.5.15) by clicking on the cogwheel in the corner and choosing Local Update. [probably skippable I just wanted to make sure it works]

5) Boot into android again and install OTA_27 (OOS 5.0) with System Update again.

6) If it doesn't boot, go to Bootloader and flash TWRP. Once in the recovery and you go to install and if you find all the folders have random numbers and letters for names then the storage in encrypted.

7) Format to get rid of encryption (random name folders) then reboot to Recovery and Flash OTA_27 again and let it start fresh on OOS 5.0 to make sure it's still booting and working.

8) Once booted Flash OTA_037 (OOS 5.1.4) wait for vendor partition to be created (took 10 mins on my OP5), reboot to TWRP and format if folders are encrypted and reflash OTA_037 if needed.

Once booted into android this is the point where you should have the Vendor Partition already created by the factory image, you can go back into TWRP (flash TWRP if needed) and under Mount be able to see, mount/unmount a Vendor partition without errors. This should solve the Error 7 problem with factory images. A newer version of TWRP Recovery should work now, I installed 3.4.0 from mauronofrio Here. 3.4.0 works with android 10.0 so I was glad.

9) Boot android again and flash OTA_038 (OOS 5.1.5) just to make sure with stock recovery. [Probably skippable but I was a Paranoid Android at this point, just to make sure it still works]

10) Boot to android again and install OTA_042 (OOS 9.0.0) with System Update to keep making sure it works. [Again, I was Paranoid. Probably Skippable]

11) Boot to android again and install OTA_054 (OOS9.0.11) as last Android 9 update to have things set up ok.

12) Boot into Android again and install the latest android 10 from OnePlus (OTA_068) with System Update and the Stock Recovery, this is Android 10.0.0 and OOS 10.0.0. Things should work fine at this point but I doubt the check for update will get new oneplus updates. As of Sep 25, 2020 it is up to date. Technically.

I should add something else I discovered after. I found a flashable zip file from one of the lineage OS posts of a oneplus5_vendor_5.1.5.zip Here. You might be able to just use that to create the Vendor partition then just Flash one of the OOS 5.X Firmwares and go from there, I've not tried it so I'm not 100% sure but it's a possibility?

Hope this is helpful to someone at some point in time. for troubleshooting at least. Honestly really glad I have a working phone right now.