{"record":{"id":"3451421fd3e3fcdf","repo":"toeverything/AFFiNE","slug":"errorcode-transformererror","errorCode":"ErrorCode.TransformerError","errorMessage":"value is required","messagePattern":"value is required","errorType":"exception","errorClass":"BlockSuiteError","httpStatus":null,"severity":"error","filePath":"blocksuite/framework/store/src/adapter/assets.ts","lineNumber":34,"sourceCode":"  }\n\n  list() {\n    return Array.from(this._map.keys());\n  }\n\n  async set(value: Blob): Promise<string>;\n\n  async set(key: string, value: Blob): Promise<string>;\n\n  async set(valueOrKey: string | Blob, _value?: Blob) {\n    const key =\n      typeof valueOrKey === 'string'\n        ? valueOrKey\n        : await sha(await valueOrKey.arrayBuffer());\n    const value = typeof valueOrKey === 'string' ? _value : valueOrKey;\n\n    if (!value) {\n      throw new BlockSuiteError(\n        ErrorCode.TransformerError,\n        'value is required'\n      );\n    }\n\n    this._map.set(key, value);\n    return key;\n  }\n}\n\nexport const mimeExtMap = new Map([\n  ['application/epub+zip', 'epub'],\n  ['application/gzip', 'gz'],\n  ['application/java-archive', 'jar'],\n  ['application/json', 'json'],\n  ['application/ld+json', 'jsonld'],\n  ['application/msword', 'doc'],\n  ['application/octet-stream', 'bin'],","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/blocksuite/framework/store/src/adapter/assets.ts#L16-L52","documentation":"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'.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Pass the Blob: assets.set(key, blob) with a real Blob/File, or use the single-argument form set(blob).","Validate the value before calling: if (!(value instanceof Blob)) skip/handle.","Where the blob may be absent, resolve it first (e.g. from blob storage by id) and only set() when found."],"exampleFix":"// before\nawait assets.set(blobId); // no value\n\n// after\nconst blob = await assets.get(blobId);\nif (blob) await assets.set(blobId, blob);","handlingStrategy":"validation","validationCode":"if (value instanceof Blob) {\n  await assets.set(key, value); // or assets.set(value) to derive the key\n}","typeGuard":"function isBlob(v: unknown): v is Blob {\n  return typeof Blob !== 'undefined' && v instanceof Blob;\n}","tryCatchPattern":null,"preventionTips":["Always pass both arguments in the two-arg form, or use the single-Blob form.","Never pipe possibly-undefined lookups (get() results) straight into set().","Type the wrapper helper as (key: string, value: Blob) so TS flags missing args."],"tags":["blocksuite","assets","blob","argument-validation","transformer"],"backgroundTag":"missing-required-argument","analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}