{"record":{"id":"39af37a3b8d3e927","repo":"TanStack/query","slug":"in-file-filepath-at-line-node-loc-start-line-39af37","errorCode":null,"errorMessage":"In file ${filePath} at line ${node.loc.start.line} the type of the \\`${keyName}\\` couldn't be recognized, so the codemod couldn't be applied. Please migrate manually.","messagePattern":"In file (.+?) at line (.+?) the type of the \\\\`(.+?)\\\\` couldn't be recognized, so the codemod couldn't be applied\\. Please migrate manually\\.","errorType":"exception","errorClass":"UnprocessableKeyError","httpStatus":null,"severity":"warning","filePath":"packages/query-codemods/src/v4/utils/replacers/key-replacer.cjs","lineNumber":66,"sourceCode":"      // When the node is an identifier at first, we try to find its declaration, because we will try\n      // to guess its type.\n      const variableDeclaration = findVariableDeclaration(node)\n\n      if (!variableDeclaration) {\n        throw new UnprocessableKeyError(\n          `In file ${filePath} at line ${node.loc.start.line} the type of identifier \\`${node.name}\\` couldn't be recognized, so the codemod couldn't be applied. Please migrate manually.`,\n        )\n      }\n\n      const initializer = variableDeclaration.value.init\n\n      // When it's a string, we just wrap it into an array expression.\n      if (isStringLiteral(initializer) || isTemplateLiteral(initializer)) {\n        return jscodeshift.arrayExpression([node])\n      }\n    }\n\n    throw new UnprocessableKeyError(\n      `In file ${filePath} at line ${node.loc.start.line} the type of the \\`${keyName}\\` couldn't be recognized, so the codemod couldn't be applied. Please migrate manually.`,\n    )\n  }\n\n  const createKeyProperty = (node) =>\n    jscodeshift.property(\n      'init',\n      jscodeshift.identifier(keyName),\n      createKeyValue(node),\n    )\n\n  const getPropertyFromObjectExpression = (objectExpression, propertyName) =>\n    objectExpression.properties.find(\n      (property) => property.key.name === propertyName,\n    ) ?? null\n\n  const buildWithTypeArguments = (node, builder) => {\n    const newNode = builder(node)","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/TanStack/query/blob/159982c80b844487054155c38ffc760fe4208daf/packages/query-codemods/src/v4/utils/replacers/key-replacer.cjs#L48-L84","documentation":"Catch-all `UnprocessableKeyError` at the end of the v4 `key-replacer.cjs` transform. If the AST node for the key matched none of the recognized shapes (string literal, template literal, identifier with known declaration, array expression, object expression), the codemod cannot guess how to wrap it and asks the user to migrate manually, citing the line and the unresolved key name.","triggerScenarios":"A query key node that is a `LogicalExpression` (`a || b`), a `ConditionalExpression` (`cond ? x : y`), a `CallExpression` (`getKey()`), a `MemberExpression` (`obj.key`), or any non-literal/non-identifier form; spread elements in arrays; binary expressions building keys.","commonSituations":"Dynamic key construction via helper functions; ternary-computed keys; keys referencing object properties; codemod run against code using non-trivial expressions in the key position.","solutions":["Manually convert the call to the v4+ key-array form, e.g. `useQuery({ queryKey: [cond ? 'a' : 'b'], queryFn })`.","Simplify the expression to a `const` array literal so the codemod can transform it, then re-run.","Inspect the cited line and apply the v4 key-array convention by hand.","Run the codemod on simpler files first and address complex ones manually."],"exampleFix":"// before\nuseQuery(getKey() || 'fallback', fetchFn)\n// after (manual)\nuseQuery({ queryKey: [getKey() || 'fallback'], queryFn: fetchFn })","handlingStrategy":"try-catch","validationCode":"// Pre-check: is the key node one of the codemod's recognized shapes?\nfunction isRecognizableKeyShape(node: any): boolean {\n  return ['Literal', 'TemplateLiteral', 'Identifier', 'ArrayExpression', 'ObjectExpression'].includes(node?.type)\n}","typeGuard":null,"tryCatchPattern":"try { transform(file) } catch (e) { if (e.name === 'UnprocessableKeyError') manualQueue.push({ file, line: e.message }) }","preventionTips":["Reduce complex key expressions (calls, ternaries, member access) to array literals before codemod.","Run the codemod in small batches and review failures per-file.","Track each cited line in a migration checklist.","Hoist helper-built keys into named `const` arrays."],"tags":["codemod","v4-migration","ast","manual-migration","key-replacer"],"backgroundTag":null,"analyzedSha":"159982c80b844487054155c38ffc760fe4208daf","analyzedAt":"2026-08-12T16:21:52.822Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}