Netlify Function with FaunaDB Query failed: Ref refers to undefined index

Help, I can’t figure out what went wrong.
Netlify Function with FaunaDB Query failed: Ref refers to undefined index

The outcome of deployed function is different to the outcome of localhost.

Outcome: /getUser?id=nik

{"build":1028,"message":"Query failed: Ref refers to undefined index 'users_id'"}

locahost: /getUser?id=nik



"use strict";

const { handle, json, message } = require('./utils/main');
const { q, client, getFaunaErrorMessage } = require('./utils/fauna');
const { env } = process, e=env;

const build=1028;

exports.handler = handle(async function(event,context) {

  { id } = event.queryStringParameters;

  return client(
    q.Get(q.Match(q.Index("users_id"), id||'' ))
    return json(500,{
      message:'Query failed: '+getFaunaErrorMessage(error)



>netlify deploy --alias=1028
Deploy path:        \_site
Functions path:     \_functions
Configuration path: \netlify.toml
Deploying to draft URL...
√ No cached functions were found
√ Finished hashing 10 files and 2 functions
√ CDN requesting 0 files and 2 functions
√ Finished uploading 2 assets
√ Deploy is live!

Website Draft URL:

FaunaDB: Running Shell Query with Server key
Outcome just fine.

Get(Match(Index("users_id"), "nik"))

    data: [Collection("users")]
    data: [Index("users_id")]
    ref: Ref(Collection("users"), "315756321428210252"),
    ts: 1637387544000000,
    data: {
      id: "nik"

I wonder what went wrong?

Hi @nikahmad,

Welcome to our forums!

It’s not clear what’s happening but we think it might be tied to your Netlify config. We’d like to review that with you, but don’t want you to share those details with the world at large. So, instead, please go to our helpdesk and open a ticket (you’ll need to create an account there, it’s not tied to the same auth system as the Fauna dashboard yet) and include a copy of your Netlify config file with it.

We’ll take a look and see if we can reproduce the error.


1 Like

Ok, I’ve sent a ticket #1175 to the Helpdesk regarding this matter. Thanks