denoland/deno · error · Error
'options' requires at least one option to be true
Error message
'options' requires at least one option to be true
What it means
Deno.open/Deno.openSync options must select at least one capability (read, write, append, truncate, create, or createNew set to true). An options object in which every flag is false declares no access at all and is rejected before any filesystem call. read defaults to true, so this almost always means read: false was passed with every other flag false or absent.
Solutions
- Ensure at least one capability flag is true, e.g. add read: true or write: true
- For plain reading, rely on the default: Deno.open(path) with no options opens read-only
- Validate computed option objects in a shared buildOpenOptions() helper before calling open
Example fix
// before
const f = await Deno.open(path, { read: false, write: false });
// after
const f = await Deno.open(path, { read: true }); Defensive patterns
Strategy: validation
Validate before calling
function buildOpenOptions(path, flags = {}) {
const o = { read: true, ...flags };
const anyTrue = Object.values(o).some((v) => v === true);
if (!anyTrue) o.read = true; // sane default instead of throwing
return o;
}
const f = await Deno.open(path, buildOpenOptions(path, computedFlags)); Prevention
- Default to { read: true } when building options dynamically
- Assert at least one flag is true before calling open in shared helpers
- Avoid negated flag logic that can zero out every capability
When it happens
Trigger: Deno.open(path, { read: false }); option objects built dynamically (e.g. from CLI flags) where every condition evaluated false; spreading a base object whose true flags were overridden to false.
Common situations: Flag-parsing code that starts from all-false and ORs conditions together; negation logic such as { read: !writeMode, write: false }; merging option presets so that no flag survives as true.
Related errors
- 'create' or 'createNew' options require 'write' or 'append'…
- 'truncate' option requires 'write' to be true
- invalid , must not be infinity or NaN
- Must be a file URL
- A file exists at the destination
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/8b7fe20b8064069c.
Report an issue: GitHub.
Appendix: source
Thrown at ext/fs/30_fs.js:801
}
async unlock() {
await op_fs_funlock_async(this.#rid);
}
[SymbolDispose]() {
core.tryClose(this.#rid);
}
}
function checkOpenOptions(options) {
if (
ArrayPrototypeFilter(
ObjectValues(options),
(val) => val === true,
).length === 0
) {
throw new Error(
"'options' requires at least one option to be true",
);
}
if (options.truncate && !options.write) {
throw new Error(
"'truncate' option requires 'write' to be true",
);
}
const createOrCreateNewWithoutWriteOrAppend =
(options.create || options.createNew) &&
!(options.write || options.append);
if (createOrCreateNewWithoutWriteOrAppend) {
throw new Error(
"'create' or 'createNew' options require 'write' or 'append' to be true",
);View on GitHub (pinned to 9ad36f7a2c)