{"record":{"id":"e16e32fa104eecff","repo":"remix-run/remix","slug":"cannot-specify-both-only-and-exclude-options-e16e32","errorCode":null,"errorMessage":"Cannot specify both \"only\" and \"exclude\" options","messagePattern":"Cannot specify both \"only\" and \"exclude\" options","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/fetch-router/src/lib/route-helpers/resources.ts","lineNumber":69,"sourceCode":"      exclude?: ResourcesMethod[]\n      only?: never\n    }\n)\n\n/**\n * Create a route map with standard CRUD routes for a resource collection.\n *\n * @param base The base route pattern to use for the resources\n * @param options Options to configure the resource routes\n * @returns The route map with CRUD routes\n */\nexport function createResourcesRoutes<base extends string, const options extends ResourcesOptions>(\n  base: base | RoutePattern<base>,\n  options?: options,\n): BuildResourcesMap<base, options> {\n  // Runtime validation\n  if (options?.only && options?.exclude) {\n    throw new Error('Cannot specify both \"only\" and \"exclude\" options')\n  }\n\n  // Resolve which methods to include\n  let only: readonly ResourcesMethod[]\n  if (options?.only) {\n    only = options.only\n  } else if (options?.exclude) {\n    only = ResourcesMethods.filter((m) => !options.exclude!.includes(m))\n  } else {\n    only = ResourcesMethods\n  }\n\n  let param = options?.param ?? 'id'\n  let indexName = options?.names?.index ?? 'index'\n  let newName = options?.names?.new ?? 'new'\n  let showName = options?.names?.show ?? 'show'\n  let createName = options?.names?.create ?? 'create'\n  let editName = options?.names?.edit ?? 'edit'","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/fetch-router/src/lib/route-helpers/resources.ts#L51-L87","documentation":"createResourcesRoutes (the collection/statistics variant) accepts either an `only` or an `exclude` method filter, not both. Passing both truthy options throws this runtime validation error before any routes are built.","triggerScenarios":"createResourcesRoutes('/users', { only: ['index'], exclude: ['stats'] }) or merged option objects where both keys survive.","commonSituations":"Shared defaults objects that include exclude being combined with a call-site only (or vice versa); copy-pasting options between route helpers.","solutions":["Remove one of the two options from the call","Sanitize merged options so only one filter key is present","Adopt a single filtering convention (only or exclude) across the codebase"],"exampleFix":"// before\ncreateResourcesRoutes('/users', { ...defaults, only: ['index'] }) // defaults has exclude\n// after\ncreateResourcesRoutes('/users', { ...defaults, only: ['index'], exclude: undefined })","handlingStrategy":"validation","validationCode":"if (options?.only && options?.exclude) throw new Error('only and exclude are mutually exclusive')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Sanitize merged configs: delete options.exclude when setting only","Keep route-helper option presets minimal to avoid accidental overlap"],"tags":["fetch-router","routes","options"],"backgroundTag":"conflicting-options","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}