{"record":{"id":"6a3b3097f3625e4c","repo":"windmill-labs/windmill","slug":"no-script-options-passed","errorCode":null,"errorMessage":"No script options passed","messagePattern":"No script options passed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts","lineNumber":3479,"sourceCode":"\t\t\t\t\t? expandedInstructions\n\t\t\t\t\t: '(the user sent an empty message)'\n\t\t\t// Deliver background-job completions to the model as a preamble on this\n\t\t\t// turn (notify-only wake). Folded into the model-facing text only — the\n\t\t\t// display bubble keeps this.instructions, and no extra message is added, so\n\t\t\t// the display↔messages index pairing above stays intact. Ephemeral.\n\t\t\tconst jobNotesPreamble =\n\t\t\t\tthis.mode === AIMode.GLOBAL && this.pendingJobNotes.length > 0\n\t\t\t\t\t? this.pendingJobNotes.join('\\n\\n') + '\\n\\n'\n\t\t\t\t\t: ''\n\t\t\tif (jobNotesPreamble) this.pendingJobNotes = []\n\t\t\tconst modelInstructions =\n\t\t\t\tthis.mode === AIMode.GLOBAL\n\t\t\t\t\t? jobNotesPreamble + this.expandGlobalSkillCommand(oldInstructions)\n\t\t\t\t\t: oldInstructions\n\t\t\tthis.instructions = ''\n\n\t\t\tif (this.mode === AIMode.SCRIPT && !this.scriptEditorOptions && !options.lang) {\n\t\t\t\tthrow new Error('No script options passed')\n\t\t\t}\n\n\t\t\t// Message-attached files travel as references: the prompt lists them by id\n\t\t\t// and the model reads their content via the file tools. Register them in\n\t\t\t// the store before the request goes out so this turn's reads can already\n\t\t\t// see them. Registration failure must not block the send — the reference\n\t\t\t// just reads as missing and the model reports it.\n\t\t\tif (this.mode === AIMode.GLOBAL && files.length > 0) {\n\t\t\t\ttry {\n\t\t\t\t\tthis.attachedFiles.registerMessageFiles(files as (AttachedTextFile & { id: string })[])\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.error('Failed to register message-attached files', e)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet userMessage: ChatCompletionMessageParam = {\n\t\t\t\trole: 'user',\n\t\t\t\tcontent: ''","sourceCodeStart":3461,"sourceCodeEnd":3497,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts#L3461-L3497","documentation":"sendRequest throws this when mode is AIMode.SCRIPT and neither scriptEditorOptions nor a `lang` option was provided. Script generation needs the language and editor context; without either, the request cannot be built correctly.","triggerScenarios":"Calling sendRequest with mode=SCRIPT while scriptEditorOptions is unset and options.lang is omitted — typically a programmatic/CLI-driven call or a chat mounted outside the script editor.","commonSituations":"Custom integrations invoking the AI manager directly and forgetting the lang option; chat component reused in a page with no script editor bound; refactor removed the options wiring.","solutions":["Pass `lang` in the sendRequest options, e.g. { mode: AIMode.SCRIPT, lang: 'bun' }.","Wire scriptEditorOptions into the manager when using script mode.","Only use SCRIPT mode from a context where the script editor is present.","Default to GLOBAL mode if no script target exists."],"exampleFix":"// before\nawait manager.sendRequest({ instructions: 'write a scraper', mode: AIMode.SCRIPT })\n// after\nawait manager.sendRequest({ instructions: 'write a scraper', mode: AIMode.SCRIPT, lang: 'bun' })","handlingStrategy":"validation","validationCode":"if (mode === AIMode.SCRIPT && !lang) {\n  throw new Error('SCRIPT mode requires a lang option')\n}","typeGuard":null,"tryCatchPattern":"try {\n  await manager.sendRequest({ instructions, mode: AIMode.SCRIPT, lang })\n} catch (e) {\n  if (e.message === 'No script options passed') {\n    await manager.sendRequest({ instructions, mode: AIMode.SCRIPT, lang: 'bun' })\n  } else throw e\n}","preventionTips":["Always pass lang with SCRIPT mode in programmatic calls.","Wire scriptEditorOptions when embedding the chat in script pages.","Use GLOBAL mode when no script target exists."],"tags":["ai","script","missing-argument","copilot"],"backgroundTag":"missing-required-argument","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}