{"record":{"id":"6d312c7740200a16","repo":"medusajs/medusa","slug":"policy-with-id-req-params-id-not-found","errorCode":null,"errorMessage":"Policy with id: ${req.params.id} not found","messagePattern":"Policy with id: (.+?) not found","errorType":"exception","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/admin/rbac/policies/[id]/route.ts","lineNumber":37,"sourceCode":"/**\n * @ignore\n * @featureFlag rbac\n */\nexport const GET = async (\n  req: AuthenticatedMedusaRequest,\n  res: MedusaResponse\n) => {\n  const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)\n  const { data: policies } = await query.graph({\n    entity: \"rbac_policy\",\n    filters: { id: req.params.id },\n    fields: req.queryConfig.fields,\n  })\n\n  const policy = policies[0]\n\n  if (!policy) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Policy with id: ${req.params.id} not found`\n    )\n  }\n\n  res.status(200).json({ policy })\n}\n\n/**\n * @ignore\n * @featureFlag rbac\n */\nexport const POST = async (\n  req: AuthenticatedMedusaRequest<AdminUpdateRbacPolicyType>,\n  res: MedusaResponse\n) => {\n  const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)\n  const { data: existing } = await query.graph({","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/rbac/policies/[id]/route.ts#L19-L55","documentation":"Thrown by GET /admin/rbac/policies/:id when the RBAC policy query returns an empty array. The policy is fetched by id with the requested fields; no match means the policy does not exist.","triggerScenarios":"Calling GET /admin/rbac/policies/pol_123 for a policy id that was deleted or never created.","commonSituations":"Admin RBAC editors with stale policy lists after policies were removed or regenerated, or scripts referencing policies from another environment.","solutions":["List policies (GET /admin/rbac/policies) to confirm the id exists","If policies were regenerated, update references to the new ids","Handle 404 by refreshing the policies list in the UI"],"exampleFix":"// before\nconst { policy } = await sdk.client.fetch(`/admin/rbac/policies/${id}`)\n\n// after\nconst { policies } = await sdk.client.fetch(\"/admin/rbac/policies\")\nif (!policies.some((p) => p.id === id)) throw new Error(`Policy ${id} not found`)\nconst policy = policies.find((p) => p.id === id)","handlingStrategy":"validation","validationCode":"const { policies } = await sdk.client.fetch(\"/admin/rbac/policies\")\nif (!policies.some((p) => p.id === policyId)) throw new Error(`Policy ${policyId} not found`)","typeGuard":"const isPolicy = (v: unknown): v is { id: string } & Record<string, unknown> =>\n  !!v && typeof v === \"object\" && \"id\" in v","tryCatchPattern":"try {\n  return await getPolicy(id)\n} catch (e: any) {\n  if (e.statusCode === 404) return null\n  throw e\n}","preventionTips":["Refetch RBAC policies before editing","Update references after policy regeneration","Scope policy ids per environment"],"tags":["admin","rbac","policies","not-found","rest-api"],"backgroundTag":"resource-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}