{"record":{"id":"9e881b9d3854b716","repo":"vercel/ai","slug":"google-interactions-cannot-stream-a-background-in","errorCode":null,"errorMessage":"google.interactions: cannot stream a background interaction without an id.","messagePattern":"google\\.interactions: cannot stream a background interaction without an id\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/google/src/interactions/stream-google-interactions.ts","lineNumber":53,"sourceCode":"export function streamGoogleInteractionEvents({\n  baseURL,\n  interactionId,\n  headers,\n  fetch,\n  abortSignal,\n  maxRetries = DEFAULT_MAX_RETRIES,\n  retryDelayMs = DEFAULT_RETRY_DELAY_MS,\n}: {\n  baseURL: string;\n  interactionId: string;\n  headers: Record<string, string | undefined>;\n  fetch?: FetchFunction;\n  abortSignal?: AbortSignal;\n  maxRetries?: number;\n  retryDelayMs?: number;\n}): ReadableStream<ParseResult<GoogleInteractionsEvent>> {\n  if (interactionId.length === 0) {\n    throw new Error(\n      'google.interactions: cannot stream a background interaction without an id.',\n    );\n  }\n\n  const eventSourceHeaders = {\n    ...headers,\n    accept: 'text/event-stream',\n  };\n\n  let lastEventId: string | undefined;\n  let complete = false;\n  let attempt = 0;\n  let receivedAnyEventThisAttempt = false;\n  let currentReader:\n    | ReadableStreamDefaultReader<ParseResult<GoogleInteractionsEvent>>\n    | undefined;\n\n  /*","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/google/src/interactions/stream-google-interactions.ts#L35-L71","documentation":"streamGoogleInteractionEvents consumes server-sent events for an already-created background interaction, which requires a valid interactionId. When the id string is empty it cannot build the event-source request, so it throws immediately before opening the stream. This guards against programming errors where an id was never assigned or was lost between creating and streaming the interaction.","triggerScenarios":"Calling the interactions streaming path with interactionId set to '' — typically when a variable holding the id was never populated or the create response's id field was not extracted.","commonSituations":"Destructuring the create-interaction response and missing the id field; passing a user-supplied id that was blank; reordering code so streaming happens before the id is known.","solutions":["Ensure the interaction is created first and capture its id from the POST response before streaming.","Add a truthiness check on the id before calling the streaming API.","If using a non-background interaction, use the non-streaming or inline path instead of streaming by id."],"exampleFix":"// before\nawait streamGoogleInteraction({ interactionId: created.id ?? '' });\n// after\nif (!created.id) throw new Error('interaction id missing from create response');\nawait streamGoogleInteraction({ interactionId: created.id });","handlingStrategy":"validation","validationCode":"if (typeof interactionId !== 'string' || interactionId.length === 0) {\n  throw new Error('interactionId is required before streaming');\n}\nawait streamGoogleInteraction({ interactionId });","typeGuard":"function hasInteractionId(v: unknown): v is string {\n  return typeof v === 'string' && v.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always capture the id from the create-interaction POST response before streaming.","Type the id as `string` (not `string | undefined`) after creation to get compiler help.","Never pass empty-string defaults for ids."],"tags":["google-interactions","missing-argument","streaming"],"backgroundTag":"missing-required-argument","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}