Handle not existing or invalid secrets with correct log messages

also fix missing import