{"record":{"id":"7b1dfce55a7187ed","repo":"payloadcms/payload","slug":"not-found-7b1dfc","errorCode":null,"errorMessage":"Not Found","messagePattern":"Not Found","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"packages/payload/src/collections/operations/updateByID.ts","lineNumber":171,"sourceCode":"    const findOneArgs: FindOneArgs = {\n      collection: collectionConfig.slug,\n      locale: locale!,\n      req,\n      where: fullWhere,\n    }\n\n    const docWithLocales = await getLatestCollectionVersion<\n      RequiredDataFromCollectionSlug<TSlug> & TypeWithID\n    >({\n      id,\n      config: collectionConfig,\n      payload,\n      query: findOneArgs,\n      req,\n    })\n\n    if (!docWithLocales && !hasWherePolicy) {\n      throw new NotFound(req.t)\n    }\n    if (!docWithLocales && hasWherePolicy) {\n      throw new Forbidden(req.t)\n    }\n    if (!docWithLocales) {\n      throw new NotFound(req.t)\n    }\n\n    // /////////////////////////////////////\n    // Generate data for all files and sizes\n    // /////////////////////////////////////\n\n    const { data: newFileData, files: filesToUpload } = await generateFileData({\n      collection,\n      config,\n      data,\n      operation: 'update',\n      overwriteExistingFiles,","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/collections/operations/updateByID.ts#L153-L189","documentation":"Thrown during updateByID when `getLatestCollectionVersion` returns no document AND the collection's update access policy is not a where-policy (i.e. access is a simple boolean true). It means no document matches the given id, so Payload responds HTTP 404. The absence of a where-policy means there is no access restriction to hide, so a plain Not Found is correct.","triggerScenarios":"`payload.update({ id: '999' })` where id 999 does not exist; updating a document that was hard-deleted; passing an id from the wrong collection; trashed documents being excluded because `trash: false` (the default).","commonSituations":"Stale client holding an id from a deleted record; race where another request deletes the doc between read and update; the document is soft-trashed (trash enabled) and the update omits `trash: true`.","solutions":["Confirm the id exists with `payload.findByID({ id, collection })` (or a count) before updating.","If trash is enabled, pass `trash: true` to operate on trashed documents.","Handle the 404 in the caller and surface a user-friendly 'not found' message instead of retrying."],"exampleFix":"// before\nawait payload.update({ collection: 'posts', id, data })\n// after\nconst exists = await payload.findByID({ collection: 'posts', id }).catch(() => null)\nif (!exists) throw new NotFoundError('post not found')\nawait payload.update({ collection: 'posts', id, data })","handlingStrategy":"try-catch","validationCode":"const exists = await payload.findByID({ collection, id, depth: 0, req }).catch(() => null)\nif (!exists) {\n  throw new Error(`Document ${id} not found; cannot update.`)\n}\nawait payload.update({ collection, id, data, req })","typeGuard":null,"tryCatchPattern":"try {\n  await payload.update({ collection, id, data, req })\n} catch (err) {\n  if (err instanceof NotFound) {\n    // document does not exist — inform the user, do not retry blindly\n    return respond(404, 'Document not found')\n  }\n  throw err\n}","preventionTips":["Existence-check with findByID before update when the caller cannot guarantee the id.","If trash is enabled, pass `trash: true` when you intend to update soft-deleted docs.","Propagate 404s to the UI as 'not found' rather than retrying."],"tags":["collections","update","not-found","local-api"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}