windmill-labs/windmill · error

Invalid text file resource {}, `content` field absent or inv

Error message

Invalid text file resource {}, `content` field absent or invalid

What it means

A 'text file' resource in Windmill must be a JSON object with a string 'content' field. When the resource at the given path is fetched, it either isn't an object or lacks a string 'content' member, so the worker cannot obtain the file body.

Source

Thrown at backend/windmill-worker/src/ansible_executor.rs:2325

    append_logs(job_id, w_id, logs, conn).await;

    Ok(nsjail_mounts)
}

async fn get_resource_or_variable_content(
    client: &AuthedClient,
    path: &ResourceOrVariablePath,
    job_id: String,
) -> anyhow::Result<String> {
    Ok(match path {
        ResourceOrVariablePath::Resource(p) => {
            let r = client
                .get_resource_value_interpolated::<serde_json::Value>(&p, Some(job_id))
                .await?;

            r.get("content")
                .and_then(|v| v.as_str())
                .ok_or(anyhow!(
                    "Invalid text file resource {}, `content` field absent or invalid",
                    p
                ))?
                .to_string()
        }
        ResourceOrVariablePath::Variable(p) => client.get_variable_value(&p).await?,
    })
}

#[cfg(test)]
mod tests {
    use super::*;

    fn no_job_envs() -> HashMap<String, String> {
        HashMap::new()
    }

    fn args_from_json(v: serde_json::Value) -> HashMap<String, Box<RawValue>> {

View on GitHub (pinned to e474e8803c)

Solutions

  1. Edit the resource in the Windmill UI so it is a JSON object with a string field named 'content'
  2. Verify the file resource's path in the job's file_resources configuration points to the intended resource
  3. If the file is binary, use the appropriate (binary) file resource kind instead of a text file resource
  4. Re-run the job after fixing the resource

Example fix

// before
{ "path": "/etc/config.txt" }
// after
{ "path": "/etc/config.txt", "content": "key=value\n" }
Defensive patterns

Strategy: validation

Validate before calling

const res = await wmill.getResource(fileRes.resource_path);
if (typeof res?.content !== 'string') {
  throw new Error(`Resource ${fileRes.resource_path} needs a string 'content' field`);
}

Type guard

function isTextFileResource(v: unknown): v is { content: string } {
  return typeof v === 'object' && v !== null && typeof (v as any).content === 'string';
}

Prevention

When it happens

Trigger: The referenced resource (e.g. u/user/some_file) was created with a different shape (missing content key, content is a number/object, or the resource is arbitrary JSON), or the resource path points to the wrong type of object.

Common situations: Hand-edited resources missing 'content'; resources created for binary use ('content' base64 under a different key); typos pointing a text-file input at a plain credential resource.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/a3797330cf989d9a. Report an issue: GitHub.