I was getting the following errors popping up in the log whenever loading up a Project containing a midi track, and also when I click on a midi track:
2022-07-26T22:03:11 [ERROR]: ardour::connect: Invalid Source port: (system:midi_capture_Oxygen 25)
2022-07-26T22:03:11 [ERROR]: ardour::connect: Invalid Source port: (system:midi_capture_USB Midi Cable)
I used to use those Sources for midi ( Oxygen 25 and Midi Cable) but do not have them anymore (I am now using only Oxygen 49).
I finally found a way to resolve this. I am on Windows 11 at the moment, but I suspect the procedure is similar on all OSs. There was a file called port_metadata.txt which contained info on all midi devices connected and used in the past. I just deleted this file and the errors went. The file was recreated when I used my new midi controller (Oxygen 49) and it no longer looks for the old inputs. In Windows 11, the location of the file was
C:Users/User/AppData/local/Ardour6 . You will probably have to change ‘User’ to your login name. Hope this helps someone else. Also, be aware that some folders/files are hidden so you may have to unhide as necessary within the folder(s).