gchq/CyberChef · error · DishError
Error translating from
Error message
Error translating from ${Dish.enumLookup(this.type)} to ArrayBuffer: ${err} What it means
Thrown by Dish._toArrayBuffer(), the first half of _translate(), wrapping any synchronous exception from the per-type toArrayBuffer function (DishString.toArrayBuffer, DishFile.toArrayBuffer, etc.). It fires only for throws inside the function table lookup/invocation - in the browser the table returns Promises whose rejections are NOT caught here (they reject the outer translate promise). The message names the source Dish type and the inner error.
Solutions
- Read the inner ${err} in the message - it identifies which Dish*.toArrayBuffer failed and why.
- Before calling dish.get(toType)/_translate, assert dish.valid() passes so value and type are consistent.
- If the inner error references File/ListFile, confirm you are in an environment with the File API (browser, or Node >= 20 with web File) and the file content is readable.
- Avoid mutating dish.value by hand; always use dish.set() so type/value stay consistent.
Example fix
// before dish.value = 123; // type still STRING, value now a number dish.get(Dish.ARRAY_BUFFER); // _toArrayBuffer throws on DishString path // after dish.set(123, Dish.NUMBER); dish.get(Dish.ARRAY_BUFFER);
Defensive patterns
Strategy: try-catch
Validate before calling
if (!dish.valid()) {
throw new Error('Dish value/type inconsistent - fix before translate');
}
// then translate Type guard
null
Try / catch
try {
await dish.get(targetType);
} catch (e) {
if (e instanceof DishError && /translating from .* to ArrayBuffer/.test(e.message)) {
// inner translation failed - inspect e.message for the cause
}
throw e;
} Prevention
- Never mutate dish.value by hand; use set() to keep value and type consistent.
- Call dish.valid() before any translate/get/presentAs.
- Confirm File/ListFile paths run where the File API exists.
When it happens
Trigger: A Dish whose .value has drifted out of sync with .type (e.g. type is STRING but value is a number) causing DishString.toArrayBuffer to fail; a Dish.FILE in a Node environment where the File API or its content is unavailable; a Dish.BIG_NUMBER whose value is a corrupt {c,e,s} object that BigNumber rejects on serialise.
Common situations: An upstream operation mutated dish.value directly without going through set(); running browser-oriented dish translation (File/ListFile) under Node where the File constructor/blob.text behaves differently; a BigNumber that survived valid() but fails ArrayBuffer round-trip due to extreme exponent.
Related errors
- Error translating from ArrayBuffer to
- Data is not a valid
- Invalid input file type.
- No data
- No input data. Load an audio file (drag/drop or use the…
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/3f187f024cc366ae.
Report an issue: GitHub.
Appendix: source
Thrown at src/core/Dish.mjs:474
[Dish.BYTE_ARRAY]: () => Promise.resolve(DishByteArray.toArrayBuffer.bind(this)()),
},
node: {
[Dish.STRING]: () => DishString.toArrayBuffer.bind(this)(),
[Dish.NUMBER]: () => DishNumber.toArrayBuffer.bind(this)(),
[Dish.HTML]: () => DishHTML.toArrayBuffer.bind(this)(),
[Dish.ARRAY_BUFFER]: () => {},
[Dish.BIG_NUMBER]: () => DishBigNumber.toArrayBuffer.bind(this)(),
[Dish.JSON]: () => DishJSON.toArrayBuffer.bind(this)(),
[Dish.FILE]: () => DishFile.toArrayBuffer.bind(this)(),
[Dish.LIST_FILE]: () => DishListFile.toArrayBuffer.bind(this)(),
[Dish.BYTE_ARRAY]: () => DishByteArray.toArrayBuffer.bind(this)(),
}
};
try {
return toByteArrayFuncs[isNodeEnvironment() && "node" || "browser"][this.type]();
} catch (err) {
throw new DishError(`Error translating from ${Dish.enumLookup(this.type)} to ArrayBuffer: ${err}`);
}
}
/**
* Convert this.value to the given type from ArrayBuffer
*
* @param {number} toType - the Dish enum to convert to
*/
_fromArrayBuffer(toType) {
// Using 'bind' here to allow this.value to be mutated within translation functions
const toTypeFunctions = {
[Dish.STRING]: () => DishString.fromArrayBuffer.bind(this)(),
[Dish.NUMBER]: () => DishNumber.fromArrayBuffer.bind(this)(),
[Dish.HTML]: () => DishHTML.fromArrayBuffer.bind(this)(),
[Dish.ARRAY_BUFFER]: () => {},
[Dish.BIG_NUMBER]: () => DishBigNumber.fromArrayBuffer.bind(this)(),
[Dish.JSON]: () => DishJSON.fromArrayBuffer.bind(this)(),View on GitHub (pinned to 4290ea7539)