{"record":{"id":"4d6b372e941c4e70","repo":"windmill-labs/windmill","slug":"rawscript-is-required-for-rawscript-kind","errorCode":null,"errorMessage":"rawscript is required for `rawscript` kind","messagePattern":"rawscript is required for `rawscript` kind","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-api/src/jobs.rs","lineNumber":9073,"sourceCode":"            }\n        }\n        \"rawscript\" => {\n            if let Some(rawscript) = batch_info.rawscript {\n                (\n                    None,\n                    None,\n                    JobKind::Preview,\n                    rawscript.language,\n                    None,\n                    Default::default(),\n                    None,\n                    Some(rawscript.content),\n                    rawscript.lock,\n                    None,\n                    None,\n                )\n            } else {\n                Err(anyhow::anyhow!(\n                    \"rawscript is required for `rawscript` kind\"\n                ))?\n            }\n        }\n        \"flow\" => {\n            let (mut value, job_kind, path) = if let Some(value) = batch_info.flow_value {\n                (value, JobKind::FlowPreview, None)\n            } else if let Some(path) = batch_info.path {\n                let mut tx = user_db.clone().begin(&authed).await?;\n                let value_json = sqlx::query!(\n                        \"SELECT coalesce(flow_version_lite.value, flow_version.value) as \\\"value!: sqlx::types::Json<Box<RawValue>>\\\" FROM flow\n                        LEFT JOIN flow_version\n                            ON flow_version.id = flow.versions[array_upper(flow.versions, 1)]\n                        LEFT JOIN flow_version_lite\n                            ON flow_version_lite.id = flow_version.id\n                        WHERE flow.path = $1 AND flow.workspace_id = $2 LIMIT 1\",\n                        &path, &w_id\n                    )","sourceCodeStart":9055,"sourceCodeEnd":9091,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-api/src/jobs.rs#L9055-L9091","documentation":"The batch job-creation handler for kind \"rawscript\" requires the `rawscript` object (content, lock, etc.). If the batch item declares kind \"rawscript\" but the `rawscript` field is missing, this error is thrown. Pure input-validation guard.","triggerScenarios":"POSTing a batch item with kind \"rawscript\" but `batch_info.rawscript == None` — i.e. the request omits the `rawscript` object — at jobs.rs around line 9073.","commonSituations":"Flows-as-code import/export tools emitting a rawscript step without its payload; hand-written batch payloads copying a \"script\" item but only changing the kind; serialization bugs dropping the field.","solutions":["Include the `rawscript` object (with at least `content` and `lock`) in the batch item.","If you meant to reference an existing script, switch the kind to \"script\" with a `path`.","Validate your generated payload: every item with kind \"rawscript\" must carry a non-null `rawscript` field.","If it comes from a flow export tool, re-export the flow and check the step still has content."],"exampleFix":"// before\n{ \"kind\": \"rawscript\" }\n// after\n{ \"kind\": \"rawscript\", \"rawscript\": { \"content\": \"print('hi')\", \"language\": \"python3\", \"lock\": [] } }","handlingStrategy":"validation","validationCode":"if (item.kind === 'rawscript' && !item.rawscript?.content) throw new Error(`batch item ${i}: rawscript.content required for kind=rawscript`);","typeGuard":"function isRawscriptItem(item) { return item.kind === 'rawscript' && !!item.rawscript && typeof item.rawscript.content === 'string'; }","tryCatchPattern":"try {\n  await batchCreate(items);\n} catch (e) {\n  if (String(e).includes('rawscript is required')) console.error('rawscript payload missing on item', e);\n  else throw e;\n}","preventionTips":["Embed full rawscript objects (content + lock) when kind is rawscript","Use kind=script with a path if you only have a reference","Round-trip test exported flows before importing"],"tags":["validation","jobs","rawscript","missing-field"],"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"}