{"record":{"id":"38016c5e2a5363fc","repo":"google-gemini/gemini-cli","slug":"exiting-due-to-an-error-processing-the-command","errorCode":null,"errorMessage":"Exiting due to an error processing the @ command.","messagePattern":"Exiting due to an error processing the @ command\\.","errorType":"exception","errorClass":"FatalInputError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/nonInteractiveCli.ts","lineNumber":293,"sourceCode":"          // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n          query = slashCommandResult as Part[];\n        }\n      }\n\n      if (!query) {\n        const { processedQuery, error } = await handleAtCommand({\n          query: input,\n          config,\n          addItem: (_item, _timestamp) => 0,\n          onDebugMessage: () => {},\n          messageId: Date.now(),\n          signal: abortController.signal,\n          escapePastedAtSymbols: false,\n        });\n        if (error || !processedQuery) {\n          // An error occurred during @include processing (e.g., file not found).\n          // The error message is already logged by handleAtCommand.\n          throw new FatalInputError(\n            error || 'Exiting due to an error processing the @ command.',\n          );\n        }\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n        query = processedQuery as Part[];\n      }\n\n      // Emit user message event for streaming JSON\n      if (streamFormatter) {\n        streamFormatter.emitEvent({\n          type: JsonStreamEventType.MESSAGE,\n          timestamp: new Date().toISOString(),\n          role: 'user',\n          content: input,\n        });\n      }\n\n      let currentMessages: Content[] = [{ role: 'user', parts: query }];","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/cli/src/nonInteractiveCli.ts#L275-L311","documentation":"Thrown in the non-interactive CLI path when handleAtCommand() returns an error string or a null processedQuery. It is a FatalInputError (exit code 42). The @-command processor failed to resolve a file path, MCP resource, or agent referenced via @-syntax, and the error is surfaced here because non-interactive mode cannot recover from a missing include.","triggerScenarios":"Running `gemini -p \"@missing.txt ...\"` (or a prompt containing @path/@resource/@agent) where resolveFilePaths/readLocalFiles/readMcpResources returned fileResult.error or mcpResult.error, so handleAtCommand returns { processedQuery: null, error }.","commonSituations":"Typo in an @-included file path; the file is outside the workspace/glob roots and got filtered out; an MCP resource name is wrong or the MCP server is down; pasting @-syntax that resolves to zero valid targets.","solutions":["Check stderr/debug log: handleAtCommand already logged the specific resolution error before this throw.","Verify the @-referenced path exists, is inside the workspace root, and matches an allowed glob.","For @-resources, confirm the MCP server is connected and the resource name is correct.","Remove the @-include or use an absolute/relative path that resolves to a real file."],"exampleFix":"# before\ngemini -p \"@src/old-name.ts explain this\"\n# after\ngemini -p \"@src/renamed-file.ts explain this\"","handlingStrategy":"try-catch","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\n\nfunction atIncludesExist(query: string, root: string): { ok: boolean; missing: string[] } {\n  const missing: string[] = [];\n  for (const m of query.matchAll(/@([\\w./\\\\-]+\\.[\\w]+)/g)) {\n    const p = m[1];\n    if (!fs.existsSync(path.resolve(root, p))) missing.push(p);\n  }\n  return { ok: missing.length === 0, missing };\n}","typeGuard":"function isHandleAtResult(v: { processedQuery: unknown; error?: string }): v is { processedQuery: NonNullable<typeof v.processedQuery>; error?: undefined } {\n  return !!v.processedQuery && !v.error;\n}","tryCatchPattern":"try {\n  await runNonInteractive(input);\n} catch (e) {\n  if (e instanceof FatalInputError && /@ command/.test(e.message)) {\n    // exit code 42: a referenced @-file/resource was unresolvable; check the prior log line\n  }\n  throw e;\n}","preventionTips":["Pre-check @-included paths against the workspace root before launching non-interactive runs.","Keep @-includes inside the workspace and within allowed glob roots.","Validate MCP server/resource availability before referencing @-resources in pipelines."],"tags":["at-command","input","filesystem","mcp","non-interactive"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}