{"record":{"id":"7f9659b70c10f4c6","repo":"google-gemini/gemini-cli","slug":"exiting-due-to-an-error-processing-the-command-7f9659","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/nonInteractiveCliAgentSession.ts","lineNumber":286,"sourceCode":"        );\n        if (slashCommandResult) {\n          // 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          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      // Create LegacyAgentSession — owns the agentic loop","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/cli/src/nonInteractiveCliAgentSession.ts#L268-L304","documentation":"Same condition as error 102 but in the agent-session non-interactive path (nonInteractiveCliAgentSession). When no pre-formed query exists, handleAtCommand is invoked and, on error or empty processedQuery, a FatalInputError (exit code 42) is thrown. The message is a fallback; the real cause was logged by handleAtCommand.","triggerScenarios":"nonInteractiveCliAgentSession invokes handleAtCommand with the user input; it returns { processedQuery: null, error } or { processedQuery: undefined } because a file/resource/agent @-include could not be resolved.","commonSituations":"Using `gemini -p` with an @-file that does not exist, is outside the workspace, or references an unavailable MCP resource/agent.","solutions":["Inspect the prior debug/error log line emitted by handleAtCommand for the concrete reason.","Confirm the @-target exists and is within the workspace root / allowed extensions.","Validate MCP connectivity for @-resources and agent registration for @-agents.","Drop the @-include or supply a resolvable path."],"exampleFix":"# before\ngemini -p \"@docs/missing.md summarize\"\n# after\ngemini -p \"@docs/existing.md summarize\"","handlingStrategy":"try-catch","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\n\nfunction preflightAtIncludes(input: string, root: string): string[] {\n  const bad: string[] = [];\n  for (const m of input.matchAll(/@([\\w./\\\\-]+\\.[\\w]+)/g)) {\n    if (!fs.existsSync(path.resolve(root, m[1]))) bad.push(m[1]);\n  }\n  return bad;\n}","typeGuard":"function hasResolvedQuery(r: { processedQuery: unknown; error?: string }): boolean {\n  return Array.isArray(r.processedQuery) && r.processedQuery.length > 0 && !r.error;\n}","tryCatchPattern":"try {\n  await runAgentSession(input);\n} catch (e) {\n  if (e instanceof FatalInputError && /@ command/.test(e.message)) {\n    // exit code 42: handleAtCommand already logged the concrete cause\n  }\n  throw e;\n}","preventionTips":["Resolve @-file paths against the workspace root before sending non-interactive prompts.","Confirm MCP resources/agents referenced via @ are registered and reachable.","Run such prompts interactively first to surface resolution errors with full context."],"tags":["at-command","input","non-interactive","agent-session","filesystem"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}