linera-io/linera-protocol · error · std::io::Error

failed to load data blob bytes from {blob_path:?}: {e}

Error message

failed to load data blob bytes from {blob_path:?}: {e}

What it means

ClientContext::publish_data_blob reads the blob payload from disk with std::fs::read before publishing it as a data blob to a chain. This error wraps any read failure with the blob path and is purely local I/O: nothing chain-related has happened yet when it fires. The ErrorKind (NotFound, PermissionDenied, IsADirectory, …) is preserved from the OS error.

Source

Thrown at linera-client/src/client_context.rs:907

            })
            .await?;

        info!("{}", "Module published successfully!");

        info!("Synchronizing client and processing inbox");
        self.process_inbox(chain_client).await?;
        Ok(module_id)
    }

    /// Publishes a data blob loaded from the given file.
    pub async fn publish_data_blob(
        &mut self,
        chain_client: &ChainClient<Env>,
        blob_path: PathBuf,
    ) -> Result<CryptoHash, Error> {
        info!("Loading data blob file");
        let blob_bytes = fs::read(&blob_path).map_err(|e| {
            std::io::Error::new(
                e.kind(),
                format!("failed to load data blob bytes from {blob_path:?}: {e}"),
            )
        })?;

        info!("Publishing data blob");
        self.apply_client_command(chain_client, |chain_client| {
            let blob_bytes = blob_bytes.clone();
            let chain_client = chain_client.clone();
            async move {
                chain_client
                    .publish_data_blob(blob_bytes)
                    .await
                    .map_err(|error| Error::PublishDataBlob(Box::new(error)))
            }
        })
        .await?;

View on GitHub (pinned to 6c226ddcb3)

Solutions

  1. Confirm the file exists and is readable at the exact path passed (`ls -l <path>`); regenerate it with the upstream command if it was never created or was deleted.
  2. Use an absolute path, or run the CLI from the directory the relative path is meant to resolve from; check for typos in the filename.
  3. If permissions are the issue, fix ownership/permissions or run as a user that can read the file; in containers, make sure the directory is mounted.

Example fix

// before
let hash = context.publish_data_blob(&mut chain_client, blob_path.clone()).await?; // fails bare

// after
if !blob_path.is_file() {
    anyhow::bail!("blob file {} not found; run the export step first", blob_path.display());
}
let hash = context.publish_data_blob(&mut chain_client, blob_path).await?;
Defensive patterns

Strategy: try-catch

Validate before calling

let meta = std::fs::metadata(&blob_path)
    .with_context(|| format!("blob {} not found; produce it before publishing", blob_path.display()))?;
anyhow::ensure!(meta.is_file(), "{} must be a regular file", blob_path.display());

Try / catch

let hash = match context.publish_data_blob(&mut chain_client, blob_path.clone()).await {
    Ok(h) => h,
    Err(e) if e.to_string().contains("failed to load data blob bytes") => {
        anyhow::bail!("blob file {} unreadable — regenerate it, then retry", blob_path.display())
    }
    Err(e) => return Err(e),
};

Prevention

When it happens

Trigger: Calling publish_data_blob (the `linera publish-data-blob <path>` flow) with a path that does not exist, is a directory, or is not readable by the current user. It fires before the info!("Publishing data blob") step, i.e. before any network or wallet interaction.

Common situations: Publishing a blob produced by an earlier step (e.g. a formats/data blob exported by another command or CI job) that was never generated or was cleaned up; relative path from the wrong cwd; file owned by another user; path typos; publishing while the producing process still writes the file (or has failed mid-way, leaving no file).

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22). Data as JSON: /api/errors/0dd4150410706a06. Report an issue: GitHub.