Firebase Cloud Functions is returning Internal Error?

I am getting firebase Internal error and I am unable to figure out why, here is my client side code and could function and Thanks for your help and time in advance. –
Client Side Code

Future<bool> forgotPassword(String email) async {
    final functions = FirebaseFunctions.instanceFor(region: "australia-southeast1");
    // final HttpsCallableResult result =
    Map<String, dynamic> data = {
        "Email": email,
    };

    try {
      final json = jsonEncode(data);
      print(json.toString());
      await functions.httpsCallable("resetPasswordNew").call(json);

      // await auth.sendPasswordResetEmail(email: email);
      return true;
    } on FirebaseFunctionsException catch (e) {

      print(e.message);
      return false;
    }
  }

I tried without encoding it do json and directly sending the map and also tried formatting it like according to this answer and also added region in the function instance as per this

Map<String, dynamic> data = {
      "data": {
        "Email": email,
      },
    };

This is my cloud function which is meant to 1. Generate a temporary password, 2. Update the user password using auth, 3. Update the firestore collection with that temporary password and 4. finally send email to the user about that password.

const functions = require("firebase-functions");
const admin = require("firebase-admin");
const logger = require("firebase-functions/logger");
const emailHelper = require("./email.helper");
const fs = require('fs');
const { HttpsError } = require("firebase-functions/v1/auth");
const app = admin.initializeApp();
const auth = admin.auth(app);
const userCollection = admin.firestore().collection('User_Info');


exports.resetPasswordNew = functions.https.onCall(async (data) => {

  const userData = data;

  const dest = userData["Email"];
  const subject = `Password Reset Email`;
  
function generatePassword() {
    // Define a list of characters to choose from
    const characters = "ABCDEFGHJKLMNPQRSTUVWXYZ";
    const numbers = "23456789"
    // Initialize the password string
    let password = '';
    // Generate the password by randomly selecting characters from the list
    for (let i = 0; i < 3; i++) {
        const randomIndex = Math.floor(Math.random() * characters.length);
        password += characters[randomIndex];
    }
    for (let i = 0; i < 5; i++) {
        const randomIndex = Math.floor(Math.random() * numbers.length);
        password += numbers[randomIndex];
    }
    return password;
}

const tempPassword = generatePassword()

  try {

    const userRecord = await auth.getUserByEmail(userData["Email"]);

    await auth.updateUser(userRecord.uid, {
      password: tempPassword,
    });

    // Remove after Emails are streamlined.
    userData["Is_Password_Temporary"] = true;
    userData["Temporary_Password"] = tempPassword;


    await userCollection.doc(userRecord.uid).set(userData, { merge: true });
    // await userCollection.doc(user.uid).create(userData);

    // userData["userID"] = user.uid;
    // userData["Temporary_Password"] = null;


  } catch (error) {
    logger.error(error.code);
    logger.error(error.message);
    throw new HttpsError('unknown', error.message);
  }

  fs.readFile('./invitation.html', 'utf8', (err, template) => {
    if (err) {
      logger.error(err);
    } else {

      const invitationData = {
        "%Name%": userData["FirstName"] || "",
        "%Username%": userData["Email"],
        "%Password%": tempPassword,
        "%Institute Name%": userData["institutionName"] || "",
      };

      Object.keys(invitationData).forEach(key => {
        template = template.replace(key, invitationData[key]);
      });

      emailHelper.sendEmail(dest, subject, template, (err, res) => {

        if (err) {
          logger.error(err);
          logger.error(`Error sending Email to ${dest}`);
        } else {
          logger.log(`Welcome Email sent to ${dest}`);
        }

      });

    }
  });

  return userData;
});

Update: There are no errors shown in Cloud Functions Metrices, and I tried the function by removing the email part and still I am receiving the Internal error. I also copied the function to uscentral1 from Australia-southeast but that doesn’t seem to make any difference too.

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật