{"record":{"id":"76a24e668738c586","repo":"denoland/deno","slug":"the-provided-value-desc-name-is-not-a-valid","errorCode":null,"errorMessage":"The provided value \"${desc?.name}\" is not a valid permission name","messagePattern":"The provided value \"(.+?)\" is not a valid permission name","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"runtime/js/10_permissions.js","lineNumber":216,"sourceCode":"\nclass Permissions {\n  constructor(key = null) {\n    if (key != illegalConstructorKey) {\n      throw new TypeError(\"Illegal constructor\");\n    }\n  }\n\n  query(desc) {\n    try {\n      return PromiseResolve(this.querySync(desc));\n    } catch (error) {\n      return PromiseReject(error);\n    }\n  }\n\n  querySync(desc) {\n    if (!isValidDescriptor(desc)) {\n      throw new TypeError(\n        `The provided value \"${desc?.name}\" is not a valid permission name`,\n      );\n    }\n\n    formDescriptor(desc);\n\n    const status = opQuery(desc);\n    return cache(desc, status);\n  }\n\n  revoke(desc) {\n    try {\n      return PromiseResolve(this.revokeSync(desc));\n    } catch (error) {\n      return PromiseReject(error);\n    }\n  }\n","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/runtime/js/10_permissions.js#L198-L234","documentation":"Deno.permissions.query/querySync validate the descriptor before touching the permission backend: it must be a non-null object whose `name` is one of read, write, net, env, sys, run, ffi, import (the permissionNames list in runtime/js/10_permissions.js). Anything else throws TypeError(`The provided value \"${desc?.name}\" is not a valid permission name`) — with 'undefined' interpolated when the argument is missing or not an object. The async query() surfaces this as a rejected promise.","triggerScenarios":"`Deno.permissions.query({ name: 'fs' })` (Node-style naming); typos like 'reads' or 'network'; `Deno.permissions.query('read')` (a string, not an object); calling with no argument at all.","commonSituations":"Porting Node scripts that reason about fs/net permissions; building descriptors dynamically from config; expecting hyphenated CLI flag names (--allow-read) instead of the bare name 'read'.","solutions":["Use exactly one of: read, write, net, env, sys, run, ffi, import — with the per-name field (path, host, command, variable, kind) where applicable","Validate the descriptor with a type guard before calling query (see defense)","If the name comes from config, check it against a const array and fail early with your own error","Remember the async variant rejects rather than throwing synchronously — attach .catch while debugging"],"exampleFix":"// before\nawait Deno.permissions.query({ name: 'fs', path: '/tmp' });\n\n// after\nawait Deno.permissions.query({ name: 'read', path: '/tmp' });","handlingStrategy":"type-guard","validationCode":"const PERMISSION_NAMES = ['read', 'write', 'net', 'env', 'sys', 'run', 'ffi', 'import'];\nfunction isPermissionDescriptor(d) {\n  return typeof d === 'object' && d !== null &&\n    PERMISSION_NAMES.includes(d.name);\n}\nif (!isPermissionDescriptor(desc)) {\n  throw new TypeError(`bad permission descriptor: ${JSON.stringify(desc)}`);\n}\nconst status = await Deno.permissions.query(desc);","typeGuard":"function isPermissionDescriptor(d) {\n  return typeof d === 'object' && d !== null &&\n    ['read', 'write', 'net', 'env', 'sys', 'run', 'ffi', 'import'].includes(d.name);\n}","tryCatchPattern":"Deno.permissions.query(desc).catch((e) => {\n  if (e instanceof TypeError && e.message.includes('not a valid permission name')) {\n    // descriptor is malformed — fix name and retry with user feedback\n  } else {\n    throw e;\n  }\n});","preventionTips":["Derive descriptors from a typed const so the name cannot drift","Match CLI flag names: --allow-read maps to name 'read', not 'allow-read' or 'fs'","Remember the async APIs reject (no synchronous throw) — attach .catch during development"],"tags":["permissions","typeerror","descriptor","validation","deno"],"backgroundTag":"invalid-permission-descriptor","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}