#ERROR (payload): NotFound: The requested resource was not found.

13 messages · Page 1 of 1 (latest)

slender dirge
#

Hi everyone,

I'm encountering a peculiar error while working with Payload CMS and its access configuration. Whenever I attempt to access a specific resource, I encounter the following error:

ERROR (payload): NotFound: The requested resource was not found.
 at findByID (node_modules\payload\src\collections\operations\findByID.ts:94:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

This error seems to be related to the payload.findByID() function call within my access configuration. I've been troubleshooting this for a while now, and I'm unable to pinpoint the exact cause.

Here's the relevant part of my access configuration code:

import { Access } from 'payload/config'

export const isAdminOrHasTagGroupAccess: Access = async ({
  req: { user, payload },
  id,
}) => {
  if (user) {
    if (user.roles.includes('admin')) {
      return true
    }

    const tag = await payload.findByID({
      collection: 'tags',
      id,
      depth: 0,
    })

    if (tag) {
      const tagGroup = await payload.findByID({
        collection: 'tag_groups',
        id: tag.tag_groups as string,
        depth: 0,
      })

      if (user.tenants?.includes(tagGroup?.tenant as string)) {
        return true
      }
    }
  }

  return false
}

I've already checked if payload is not null before calling payload.findByID(), and I've ensured that the id being passed is correct.

If anyone has encountered a similar issue or has insights into what might be causing this error, I'd greatly appreciate your input. Thank you!

native dockBOT
slender dirge
#

should I use a hooks to handle this kind of situations?

toxic iris
#

I'm getting the same error. Did you figure it out?

slender dirge
#

@toxic iris nope and forget about support

#

The project is awesome, but the help is almost zero.

toxic iris
#

Idk if I blame them lol, they're a small team doing a lot at once haha

#

My problem was literally just the ID I was passing in was incorrect

silk bridge
#

Good morning

#

I can try to help

#

Also, @slender dirge we have tried to help you many times, replying to you in under 24 hours. You were rude and ungrateful in each scenario

#

The problem is not Payload in your case sadly

#

I am happy to continue helping you, but do not criticize our community please.