mattermost-community/focalboard · warning

invalid image block

Error message

invalid image block

What it means

ErrInvalidImageBlock is returned by extractFilename during archive import/export when an image block lacks the data needed to determine its filename. Image blocks are expected to reference an uploaded file with a valid path/name; a malformed or non-image block passed to the extractor yields this sentinel error.

Source

Thrown at server/model/import_export.go:10

package model

import (
	"encoding/json"
	"errors"
	"fmt"
)

var (
	ErrInvalidImageBlock = errors.New("invalid image block")
)

// Archive is an import / export archive.
// TODO: remove once default templates are converted to new archive format.
type Archive struct {
	Version int64   `json:"version"`
	Date    int64   `json:"date"`
	Blocks  []Block `json:"blocks"`
}

// ArchiveHeader is the content of the first file (`version.json`) within an archive.
type ArchiveHeader struct {
	Version int   `json:"version"`
	Date    int64 `json:"date"`
}

// ArchiveLine is any line in an archive.
type ArchiveLine struct {

View on GitHub (pinned to a84bbb65e3)

Solutions

  1. Validate the archive's image blocks include a valid file reference before import
  2. Re-export the archive from a working Boards instance
  3. Fix or drop the malformed image block from the archive JSON

Example fix

// before
block := blocks[i] // assumed image
name, err := extractFilename(block)
// after
if block.Type != model.TypeImage || block.FileId == "" {
    return fmt.Errorf("skipping invalid image block %s", block.ID)
}
name, err := extractFilename(block)
Defensive patterns

Strategy: validation

Validate before calling

if block.Type != model.TypeImage || block.FileId == "" {
    // skip or repair before calling extractFilename
}

Type guard

func isInvalidImageBlockErr(err error) bool {
    return errors.Is(err, model.ErrInvalidImageBlock)
}

Try / catch

name, err := extractFilename(block)
if errors.Is(err, model.ErrInvalidImageBlock) {
    log.Printf("skipping bad image block %s", block.ID)
    return "", nil // continue import
}

Prevention

When it happens

Trigger: Importing an archive whose image block is missing a fileId/attachment reference or has malformed content; extractFilename called on a block that is not actually an image block.

Common situations: Hand-edited or third-party-generated archive JSON files; archives exported from older Boards versions with a different block schema; corrupted uploads during migration.

Related errors


AI-assisted analysis of mattermost-community/focalboard@a84bbb65e3 (2026-08-30). Data as JSON: /api/errors/2d8a9e111d0aa198. Report an issue: GitHub.