I have this as well and have investigated it:
When loading a game or changing scene (like from space to space center), docking ports that are docked, changes to a different state than the one they were in when the involved .sfs was written (happens when saving game or switching scene).
In this new state the undock action does not work correctly.
When I look at any craft in the .sfs files, all its parts have uids set to 0.This seems to cause some issues with docking ports as they apparently need to reference connected parts/root parts correctly to function.
I don't know how gagarinekerman creates the craft, or if it's possible to change this so part uids are registered correctly, but my apparently functioning workaround is to not have anything docked when saving game or switching scene.
I don't think it's possible to edit the current .sfs files to repair this without knowing how make up uids, that can be used to configure the docked ports correctly, which I don't, unfortunately.
Hope this post is useful