{"record":{"id":"c03bc94070fe73ea","repo":"TanStack/query","slug":"bad-argument-type-starting-with-v5-only-the-obj-c03bc9","errorCode":null,"errorMessage":"Bad argument type. Starting with v5, only the \"Object\" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object","messagePattern":"Bad argument type\\. Starting with v5, only the \"Object\" form is allowed when calling query related functions\\. Please use the error stack to find the culprit call\\. More info here: https://tanstack\\.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/react-query/src/useBaseQuery.ts","lineNumber":46,"sourceCode":"  TQueryFnData,\n  TError,\n  TData,\n  TQueryData,\n  TQueryKey extends QueryKey,\n>(\n  options: UseBaseQueryOptions<\n    TQueryFnData,\n    TError,\n    TData,\n    TQueryData,\n    TQueryKey\n  >,\n  Observer: typeof QueryObserver,\n  queryClient?: QueryClient,\n): QueryObserverResult<TData, TError> {\n  if (process.env.NODE_ENV !== 'production') {\n    if (typeof options !== 'object' || Array.isArray(options)) {\n      throw new Error(\n        'Bad argument type. Starting with v5, only the \"Object\" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object',\n      )\n    }\n  }\n\n  const isRestoring = useIsRestoring()\n  const errorResetBoundary = useQueryErrorResetBoundary()\n  const client = useQueryClient(queryClient)\n  const defaultedOptions = client.defaultQueryOptions(options)\n  ;(client.getDefaultOptions().queries as any)?._experimental_beforeQuery?.(\n    defaultedOptions,\n  )\n\n  const query = client\n    .getQueryCache()\n    .get<\n      TQueryFnData,\n      TError,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/TanStack/query/blob/159982c80b844487054155c38ffc760fe4208daf/packages/react-query/src/useBaseQuery.ts#L28-L64","documentation":"Dev-only runtime guard in React Query's `useBaseQuery` (mirror of the Preact equivalent). v5 removed the positional-argument overloads in favor of a single options object; if the first argument is not a plain object (or is an array), the hook rejects it before creating an observer. Only fires outside production builds.","triggerScenarios":"Calling `useQuery(['key'], fn)` or `useQuery('key', fn)` (v4 form) under v5; passing a query-key array as the first argument; passing `null`/`undefined`; partial v4->v5 migration leaving some call sites on the old signature.","commonSituations":"Upgrading `@tanstack/react-query` from v4 to v5 without running the codemod; copying v4 examples; a custom hook that forwards positional args; libraries that wrap `useQuery` and still use the old signature.","solutions":["Migrate to the object form: `useQuery({ queryKey, queryFn })`.","Run `npx @tanstack/query-codemods remove-overloads` on the project.","Audit all `useQuery`/`useInfiniteQuery`/`useMutation` calls to confirm they pass a single object.","Refactor wrapper hooks to accept and forward an options object."],"exampleFix":"// before\nuseQuery(['todos'], fetchTodos, { enabled: false })\n// after\nuseQuery({ queryKey: ['todos'], queryFn: fetchTodos, enabled: false })","handlingStrategy":"type-guard","validationCode":"function assertQueryOptionsObject(options: unknown) {\n  if (options === null || typeof options !== 'object' || Array.isArray(options)) {\n    throw new TypeError('useQuery expects a single options object in v5')\n  }\n}","typeGuard":"const isPlainOptionsObject = (v: unknown): v is Record<string, unknown> =>\n  v !== null && typeof v === 'object' && !Array.isArray(v)","tryCatchPattern":"// Temporary compatibility shim during migration.\nfunction safeUseQuery(arg: any, fn?: any, rest?: any) {\n  if (Array.isArray(arg) || typeof arg === 'string') return useQuery({ queryKey: Array.isArray(arg) ? arg : [arg], queryFn: fn, ...(rest || {}) })\n  return useQuery(arg)\n}","preventionTips":["Run the v5 remove-overloads codemod right after upgrading.","Enable strict TypeScript to catch positional misuse at compile time.","Add an ESLint rule disallowing multi-arg query hooks.","Audit wrapper hooks to ensure they forward a single options object."],"tags":["react","v5-migration","api-contract","validation"],"backgroundTag":null,"analyzedSha":"159982c80b844487054155c38ffc760fe4208daf","analyzedAt":"2026-08-12T16:21:52.822Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}