Although I don’t (yet?) suffer this problem (perhaps because I’m a Nikon shooter?), it seems that others do. Well, at least one person does. This is why Bill Ferguson has apparently written a lua script to address this issue. Give it a shot to see what it does for you!
I took a look at that and what it seems to is fix lenses that were identified as A but should be identified as B. Since all of mine are identified as n/a with a variety of lenses I am not sure there is a good way to make that script work for me.
If I could determine what was missing it might be possible to write a script using exiftool but I am not familiar enough with darktable and exif to know what it needs to see.
Does anyone know what field/data darktable is reading to get the lens information?
I compared an image darktable can read to one that it cannot with both exiftool and exiv2 and I don’t see any obvious differences.
Since this seems to be an issue that only impacts older images in my collection I don’t have a problem with updating them via a script but I am not sure what data I would need to write to what field.
darktable seems to use LensType over LensModel so even though LensModel appears to be set when I read the exif it isn’t being read properly by darktable because LensType is not set correctly on many of these older images.
I think I can fix that without too much trouble using exiftool now that I understand it better. Since it only impacts older images for me a one-time fix should solve my issue.