{"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/26c515e050211269e911f7d9cfe162a26c83ed98/blocksuite/framework/store/src/adapter/assets.ts#L16-L52","documentation":"Thrown by `MemoryBlobCRUD.set` in assets.ts when the call resolves `value` to undefined. The method has two overloads: `set(Blob)` and `set(key, Blob)`; when called in the key form (`valueOrKey` is a string), `_value` must be supplied. If it is missing, the resolved `value` is undefined and the error fires. The class is marked `@internal just for test`.","triggerScenarios":"Calling `memoryBlob.set('some-id')` (no blob), or `memoryBlob.set('some-id', undefined)` — typically a bug in a test helper or a caller that destructured a possibly-undefined blob.","commonSituations":"Test utilities passing an optional `Blob | undefined` without a guard; refactoring the call sites to drop the second argument; misusing the internal test class in place of the real blob storage.","solutions":["Pass a non-null `Blob` as the second argument when using the `(key, value)` overload.","Narrow with `if (!blob) return;` before calling `set`.","Prefer the single-argument `set(blob)` overload when you have only a Blob (the key is derived from its sha)."],"exampleFix":"// before: key overload called without a blob\nawait memoryBlob.set(blobId); // _value is undefined\n\n// after: pass the blob explicitly\nawait memoryBlob.set(blobId, blob);\n\n// or use the single-arg overload to derive the key\nconst key = await memoryBlob.set(blob);","handlingStrategy":"validation","validationCode":"// narrow before calling the key overload\nfunction setBlob(crud: MemoryBlobCRUD, keyOrBlob: string | Blob, value?: Blob) {\n  if (typeof keyOrBlob === 'string') {\n    if (!value) throw new Error('value is required for the (key, value) overload');\n    return crud.set(keyOrBlob, value);\n  }\n  return crud.set(keyOrBlob);\n}","typeGuard":"function isBlob(v: unknown): v is Blob {\n  return v instanceof Blob;\n}","tryCatchPattern":"try {\n  await memoryBlob.set(blobId, blob);\n} catch (e) {\n  if (e instanceof BlockSuiteError && e.code === ErrorCode.TransformerError) {\n    console.error('Blob set failed:', e.message);\n  }\n}","preventionTips":["Always pass a non-null Blob with the key overload.","Prefer the single-arg set(blob) overload when only a Blob is available.","Guard optional blobs with `if (!blob) return;` before calling."],"tags":["assets","blob","transformer","internal"],"backgroundTag":null,"analyzedSha":"26c515e050211269e911f7d9cfe162a26c83ed98","analyzedAt":"2026-08-12T13:15:16.447Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}