If you could, after this line add cachedcreds ||= '', if cached credentials currently fails for whatever reason a null exception is thrown.