{"record":{"id":"8b7fe20b8064069c","repo":"denoland/deno","slug":"options-requires-at-least-one-option-to-be-true","errorCode":null,"errorMessage":"'options' requires at least one option to be true","messagePattern":"'options' requires at least one option to be true","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ext/fs/30_fs.js","lineNumber":801,"sourceCode":"  }\n\n  async unlock() {\n    await op_fs_funlock_async(this.#rid);\n  }\n\n  [SymbolDispose]() {\n    core.tryClose(this.#rid);\n  }\n}\n\nfunction checkOpenOptions(options) {\n  if (\n    ArrayPrototypeFilter(\n      ObjectValues(options),\n      (val) => val === true,\n    ).length === 0\n  ) {\n    throw new Error(\n      \"'options' requires at least one option to be true\",\n    );\n  }\n\n  if (options.truncate && !options.write) {\n    throw new Error(\n      \"'truncate' option requires 'write' to be true\",\n    );\n  }\n\n  const createOrCreateNewWithoutWriteOrAppend =\n    (options.create || options.createNew) &&\n    !(options.write || options.append);\n\n  if (createOrCreateNewWithoutWriteOrAppend) {\n    throw new Error(\n      \"'create' or 'createNew' options require 'write' or 'append' to be true\",\n    );","sourceCodeStart":783,"sourceCodeEnd":819,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/fs/30_fs.js#L783-L819","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst f = await Deno.open(path, { read: false, write: false });\n\n// after\nconst f = await Deno.open(path, { read: true });","handlingStrategy":"validation","validationCode":"function buildOpenOptions(path, flags = {}) {\n  const o = { read: true, ...flags };\n  const anyTrue = Object.values(o).some((v) => v === true);\n  if (!anyTrue) o.read = true; // sane default instead of throwing\n  return o;\n}\n\nconst f = await Deno.open(path, buildOpenOptions(path, computedFlags));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["fs","open","options","validation"],"backgroundTag":"invalid-option-combination","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}