{"record":{"id":"bfcd81e71efa2b82","repo":"remotion-dev/remotion","slug":"could-not-locate-the-visual-control-identifier","errorCode":null,"errorMessage":"Could not locate the visual control identifier","messagePattern":"Could not locate the visual control identifier","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio-codemods/src/apply-visual-control.ts","lineNumber":107,"sourceCode":"\t\t\t\t\tthrow new Error('Could not locate the visual control value');\n\t\t\t\t}\n\n\t\t\t\tconst start = recastLocToOffset(input, secondArgument.loc.start);\n\t\t\t\tconst end = recastLocToOffset(input, secondArgument.loc.end);\n\t\t\t\tconst lineStart = input.lastIndexOf('\\n', start - 1) + 1;\n\t\t\t\tedits.push({\n\t\t\t\t\tstart,\n\t\t\t\t\tend,\n\t\t\t\t\treplacement: formatSerializedValue({\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\tlinePrefix: input.slice(lineStart, start),\n\t\t\t\t\t\tpreviousValue: input.slice(start, end).trim(),\n\t\t\t\t\t\tserialized,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tif (!firstArgument.loc) {\n\t\t\t\t\tthrow new Error('Could not locate the visual control identifier');\n\t\t\t\t}\n\n\t\t\t\tconst offset = recastLocToOffset(input, firstArgument.loc.end);\n\t\t\t\tconst lineStart = input.lastIndexOf('\\n', offset - 1) + 1;\n\t\t\t\tedits.push({\n\t\t\t\t\tstart: offset,\n\t\t\t\t\tend: offset,\n\t\t\t\t\treplacement: `, ${formatSerializedValue({\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\tlinePrefix: `${input.slice(lineStart, offset)}, `,\n\t\t\t\t\t\tpreviousValue: null,\n\t\t\t\t\t\tserialized,\n\t\t\t\t\t})}`,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfor (const matchingChange of matchingChanges) {\n\t\t\t\tchangesMade.push({","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-codemods/src/apply-visual-control.ts#L89-L125","documentation":"When a visualControl() call has no second argument, the codemod appends a new value right after the first (identifier) argument. If that first argument node has no .loc, its insertion offset cannot be computed, so it throws this error.","triggerScenarios":"Visiting a visualControl(id) call (single argument) whose first argument node lacks loc — usually because the call expression was synthesized by a previous codemod or generated AST rather than parsed from original source.","commonSituations":"Codemod pipelines where a visualControl call was inserted programmatically into the AST before applyVisualControl runs.","solutions":["Re-parse the original file and run the codemod on freshly parsed source","Persist the inserted call to disk and re-run the codemod so recast assigns locations","Add the value argument manually in the editor"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"const firstArgLocated = (node: any) => node.arguments[0] && node.arguments[0].loc !== undefined;","typeGuard":"const hasLoc = (n: {loc?: unknown}): n is {loc: NonNullable<unknown>} => n.loc != null;","tryCatchPattern":"try {\n  applyVisualControl({input, transformation});\n} catch (e) {\n  if ((e as Error).message.includes('Could not locate the visual control identifier')) {\n    // re-parse original source and retry, or add the value manually\n  }\n}","preventionTips":["Apply visual-control codemods against the original file, not generated ASTs","Reformat files with prettier before running chained codemods","Write visualControl(id, value) with both arguments in literal source when possible"],"tags":["codemod","ast","source-locations"],"backgroundTag":"internal-invariant-violation","analyzedSha":"46a3a6bf13ca367376ff18bbb06dae2e87e0d068","analyzedAt":"2026-09-18T00:12:20.256Z","contentChangedAt":"2026-09-18T00:12:20.256Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}