Error Error: [C0006] Request failed, Internal Server Error(500)

Good afternoon, how are you guys? the error of [C0006] Unauthorized and [C0005] Request contains unknown parameter, in quotes I fixed it. but now it gives me this error: error: Uncaught internal server error. Cannot destructure property 'adapter' of 'loadAuthAdapter(...)' as it is undefined. {"stack":"TypeError: Cannot destructure property 'adapter' of 'loadAuthAdapter(...)' as it is undefined.\n at Object.getValidatorForProvider. I donโ€™t know if it is the correct way to call the cloud or to execute the cloud requestVerifyMessage. in this part it stops, attached login code, cloud code, and the functions I call for I get the authentication from this repo: https://github.com/MoralisWeb3/Moralis-JS-SDK/tree/main/demos/parse-server

frontend login:

const connectToMetamask = async () => {
  const provider = new ethers.providers.Web3Provider((window as any).ethereum, 'any');

  const [accounts, chainId] = await Promise.all([
    provider.send('eth_requestAccounts', []),
    provider.send('eth_chainId', []),
  ]);

  const signer = provider.getSigner();
  return { signer, chain: chainId, account: accounts[0] };
};

const Login = async () => {

    setStateCircularProgress(true);

    try {

      // Connect to Metamask

      const { signer, chain, account } = await connectToMetamask();

      console.log("signer", signer)

      console.log("chain", chain)

      console.log("account", account)

      if (!account) {

        throw new Error(

          "Connecting to chain failed, as no connected account was found"

        );

      }

      if (!chain) {

        throw new Error(

          "Connecting to chain failed, as no connected chain was found"

        );

      }

      if (chain != chainID.testNet) {

        await switchNetworkPolygon();

      }

      const { message } = await Moralis.Cloud.run("requestMessage", {

        // domain: serverUrl,

        address: account,

        chain: parseInt(chainID.testNet),

        networkType: "evm",

      });

      console.log("message", message)

      const signature = await signer.signMessage(message);

      console.log("signature", signature)

      const { user } = await Moralis.Cloud.run("requestVerifyMessage", {

        signature,

        message

      });

      console.log("user", user)

      if (user) {

        console.log('userLogin', user)

        const userMarketType = user!.get("loginType");

        console.log("user", user);

        const ethAddres = user!.get("ethAddress");

        dispatch({

          type: "USER_RENDER",

          payload: user,

        });

        dispatch({

          type: "USER_AUTHENTICATED",

          payload: true,

        });

        dispatch({

          type: "GET_LOGIN_TYPE",

          payload: userMarketType,

        });

        setValuesAlertFunc(true, "Welcome to Koolinart", "success");

        await fetchTokenBalance(ethAddres);

      }

      console.log("account", account);

      console.log("chainId", chain);

      setValuesAlertFunc(true, "Login success", "success");

      setStateCircularProgress(false);

    } catch (e) {

      const errorMessage = JSON.stringify(e);

      const errorObjeto = JSON.parse(errorMessage);

      setValuesAlertFunc(true, errorObjeto.message, "error");

      console.log("error", e);

      setStateCircularProgress(false);

    }

  };

frontend error:

error Error: [C0006] Request failed, Internal Server Error(500): Internal server error.
    at handleError (RESTController.js:438:17)
    at async Login (UserState.tsx:307:24)

cloud code:

/* eslint-disable no-console */

/* eslint-disable @typescript-eslint/no-unused-vars */

/* eslint-disable etc/no-commented-out-code */

/* eslint-disable @typescript-eslint/no-explicit-any */

/* eslint-disable @typescript-eslint/no-var-requires */

declare const Parse: any;

import "./collections"

import "./functionMarket"

import "./renderNft"

import "./stripe"

import "./user"

import "./sendingEmails"

import { requestMessage, verifyMessage } from '../auth/authService';

Parse.Cloud.define('requestMessage', async ({ params }: any) => {

  const { address, chain, networkType } = params;

  console.log('address', address)

  console.log('chain', chain)

  console.log('network', networkType)

  const message = await requestMessage({

    address,

    chain,

    networkType,

  });

  return { message };

});

Parse.Cloud.define('requestVerifyMessage', async ({ params }: any) => {

  const { message, signature } = params;

 

  const user  = await verifyMessage({

    signature,

    message,

    network: "evm"

  });

  return { user  };

});

Parse.Cloud.define('getPluginSpecs', () => {

  // Not implemented, only excists to remove client-side errors when using the moralis-v1 package

  return [];

});

Parse.Cloud.define('getServerTime', () => {

  // Not implemented, only excists to remove client-side errors when using the moralis-v1 package

  return null;

});

export default Parse

This error is due to metamask, with mail start a normal session. The screen to sign the message appears once I sign it, it returns this error:

backend error:

error: Uncaught internal server error. Cannot destructure property 'adapter' of 'loadAuthAdapter(...)' as it is undefined. {"stack":"TypeError: Cannot destructure property 'adapter' of 'loadAuthAdapter(...)' as it is undefined.\n    at Object.getValidatorForProvider (C:\\Users\\david\\Documents\\Programacion\\react\\Koolinart\\backend\\node_modules\\parse-server\\src\\Adapters\\Auth\\index.js:127:13)\n    at map (C:\\Users\\david\\Documents\\Programacion\\react\\Koolinart\\backend\\node_modules\\parse-server\\src\\RestWrite.js:430:58)\n    at Array.map (<anonymous>)\n    at RestWrite.handleAuthDataValidation (C:\\Users\\david\\Documents\\Programacion\\react\\Koolinart\\backend\\node_modules\\parse-server\\src\\RestWrite.js:426:45)\n    at C:\\Users\\david\\Documents\\Programacion\\react\\Koolinart\\backend\\node_modules\\parse-server\\src\\RestWrite.js:574:17\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)"}
ErrorHandler TypeError: Cannot destructure property 'adapter' of 'loadAuthAdapter(...)' as it is undefined.
    at Object.getValidatorForProvider (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\parse-server\src\Adapters\Auth\index.js:127:13)
    at map (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\parse-server\src\RestWrite.js:430:58)
    at Array.map (<anonymous>)
    at RestWrite.handleAuthDataValidation (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\parse-server\src\RestWrite.js:426:45)
    at C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\parse-server\src\RestWrite.js:574:17
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\express\lib\router\index.js:286:9
    at Function.process_params (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\express\lib\router\index.js:346:12)
    at next (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\express\lib\router\index.js:280:10)
    at Immediate.<anonymous> (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\express\lib\application.js:240:9)
    at Immediate._onImmediate (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\parse-server\node_modules\express\lib\router\index.js:646:15)
    at processImmediate (node:internal/timers:468:21)

johnversus, YosephKS, cryptokid please help, thanks us.

Hi @davidzuccarini

Can you share more details on how we can reproduce this error?

The way you are calling requestVerifyMessage cloud function is correct. But you would not need to call this cloud function if you are using the v1 sdk in client.

Check the code from this docs on how to you authenticate using v1 sdk.
https://v1docs.moralis.io/moralis-dapp/getting-started/self-hosting-moralis-server/client-connection#note-about-authentication

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.