Invalid parameter for query: group. Please use objectId instead of _id"

I am running into a weird issue with one of my functions. In the example below, when I only query either “query_1” or “query_2” its working normally. When I query both queries I get the error from the subject of this thread.

Doesnt make any sense to me. Why would the aggregation work on a single call but not on both?

Moralis.Cloud.define("trackWallets", async request => {
  try {
    const usd_threshold = request.params.usd_threshold || 10000;
    const pipeline = track_wallets_pipeline(usd_threshold);

    const query_1 = new Moralis.Query("EthTransactions");
    const query_2 = new Moralis.Query("EthTokenTransfers");
    const result_1 = await query_1.aggregate(pipeline);
    const result_2 = await query_2.aggregate(pipeline);
    return {
      ethTransactions: result_1.length,
      tokenTransfers: result_2.length,
      result1: result_1,
      result2: result_2
    };
  } catch (error) {
    logger.info("Error: " + error);
    return error;
  }
});
const track_wallets_pipeline = usd_threshold => [
  {
    lookup: {
      from: "_AddressSyncStatus",
      localField: "from_address",
      foreignField: "address",
      as: "synced_address"
    }
  },
  {
    unwind: {
      path: "$synced_address"
    }
  },
  {
    match: {
      $and: [
        {
          $or: [
            {
              $expr: {
                $eq: ["$from_address", "$synced_address.address"]
              }
            },
            {
              $expr: {
                $eq: ["$to_address", "$synced_address.address"]
              }
            }
          ]
        },
        {
          $expr: {
            $gt: ["$usd", 500]
          }
        },
        {
          $expr: {
            $eq: ["$is_contract_transaction", false]
          }
        }
      ]
    }
  },
  {
    group: {
      objectId: {
        from_address: "$from_address",
        to_address: "$to_address"
      },
      tx_count: {
        $sum: 1
      },
      usd: {
        $sum: "$usd"
      }
    }
  },
  {
    project: {
      _id: 0,
      from_address: "$_id.from_address",
      to_address: "$_id.to_address",
      tx_count: 1,
      usd: 1
    }
  },
  {
    sort: {
      tx_count: -1,
      usd: -1
    }
  }
];

You mean that in this case it doesn’t work with those two lines but it works with any of those two lines separately?

correct,

if I leave out anything related to query_2 its working. if I leave out anything related to query_! its working. When I run both its giving the error. Makes no sense to me

Try with two lines like this one, like pipeline1 and pipeline2

Moralis.Cloud.define("trackWallets", async request => {
  try {
    const usd_threshold = request.params.usd_threshold || 10000;
    const pipeline_1 = track_wallets_pipeline(usd_threshold);
    const pipeline_2 = track_wallets_pipeline(usd_threshold);
    const query_1 = new Moralis.Query("EthTransactions");
    const query_2 = new Moralis.Query("EthTokenTransfers");
    const result_1 = await query_1.aggregate(pipeline_1);
    const result_2 = await query_2.aggregate(pipeline_2);
    
    return {
      ethTransactions: result_1.length,
      tokenTransfers: result_2.length,
      result1: result_1,
      result2: result_2
    };
  } catch (error) {
    logger.info("Error: " + error);
    return error;
  }
});

results in the same error

edit rebooted the server, now it works with 2 pipeline constants. Still I dont understand why this is the case tho