I've been getting the same error: this looks to be an incompatibility between Aircraft Realism and AAI Programmable Vehicles (0.7.14) regarding the Cargo Plane's gun. AAI Programmable Vehicles removes the gun from the Cargo Plane because "hauler types should not have guns", presumably because it has different behavior for transport vehicles (This happens in prototypes/ai-vehicles.lua in that mod). However, this only happens after Aircraft Realism has already made a copy of the Cargo Plane for the airborne version, since that is a different entity. As a result, the gun only gets removed from the landed version of the plane, resulting in this error.
The easiest fix to this, and a workaround that you can do at home to fix this, is to change the load order such that Aircraft Realism loads after AAI Programmable Vehicles. This can be done by modifying the info.json file in the root of the Aircraft Realism mod directory, and adding "aai-programmable-vehicles" as an optional dependency. This means your "dependencies" line will go from "dependencies": ["base >= 0.18", "? Aircraft >= 1.7.0", "? betterCargoPlanes >= 1.0.8", "? Helicopters >= 0.3.14"],
to "dependencies": ["base >= 0.18", "? Aircraft >= 1.7.0", "? betterCargoPlanes >= 1.0.8", "? Helicopters >= 0.3.14", "(?) aai-programmable-vehicles"],