toeverything/AFFiNE · error · BlockSuiteError

ErrorCode.TransformerError

ErrorCode.TransformerError

Error message

value is required

What it means

AssetsManager/MemoryBlobCRUD.set() (framework/store/src/adapter/assets.ts) has two overloads — set(blob) (key derived via sha of the bytes) and set(key, blob). After normalizing arguments it requires a truthy Blob value; when the two-argument form is called with key plus an undefined blob (argument dropped, optional param never passed, or explicitly set to undefined), it throws TransformerError 'value is required'.

Solutions

  1. Pass the Blob: assets.set(key, blob) with a real Blob/File, or use the single-argument form set(blob).
  2. Validate the value before calling: if (!(value instanceof Blob)) skip/handle.
  3. Where the blob may be absent, resolve it first (e.g. from blob storage by id) and only set() when found.

Example fix

// before
await assets.set(blobId); // no value

// after
const blob = await assets.get(blobId);
if (blob) await assets.set(blobId, blob);
Defensive patterns

Strategy: validation

Validate before calling

if (value instanceof Blob) {
  await assets.set(key, value); // or assets.set(value) to derive the key
}

Type guard

function isBlob(v: unknown): v is Blob {
  return typeof Blob !== 'undefined' && v instanceof Blob;
}

Prevention

When it happens

Trigger: Calling assets.set('some-blob-id') without the second argument; passing a variable that is undefined (e.g. a lookup that returned undefined) as the value; spreading an options object that lacks the blob field into set(key, opts.blob).

Common situations: Custom adapters or asset pipelines that copy blobs by id and forget the value; refactors of the set() signature; optional-chained blob fetches ((await getBlob(id))!) whose result is undefined.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/3451421fd3e3fcdf. Report an issue: GitHub.

Appendix: source

Thrown at blocksuite/framework/store/src/adapter/assets.ts:34

  }

  list() {
    return Array.from(this._map.keys());
  }

  async set(value: Blob): Promise<string>;

  async set(key: string, value: Blob): Promise<string>;

  async set(valueOrKey: string | Blob, _value?: Blob) {
    const key =
      typeof valueOrKey === 'string'
        ? valueOrKey
        : await sha(await valueOrKey.arrayBuffer());
    const value = typeof valueOrKey === 'string' ? _value : valueOrKey;

    if (!value) {
      throw new BlockSuiteError(
        ErrorCode.TransformerError,
        'value is required'
      );
    }

    this._map.set(key, value);
    return key;
  }
}

export const mimeExtMap = new Map([
  ['application/epub+zip', 'epub'],
  ['application/gzip', 'gz'],
  ['application/java-archive', 'jar'],
  ['application/json', 'json'],
  ['application/ld+json', 'jsonld'],
  ['application/msword', 'doc'],
  ['application/octet-stream', 'bin'],

View on GitHub (pinned to b4c8548c09)