{"record":{"id":"c04921247c44f59a","repo":"denoland/deno","slug":"the-provided-value-desc-name-is-not-a-valid-c04921","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":258,"sourceCode":"    }\n\n    formDescriptor(desc);\n\n    const status = opRevoke(desc);\n    return cache(desc, status);\n  }\n\n  request(desc) {\n    try {\n      return PromiseResolve(this.requestSync(desc));\n    } catch (error) {\n      return PromiseReject(error);\n    }\n  }\n\n  requestSync(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 = opRequest(desc);\n    return cache(desc, status);\n  }\n}\n\nconst permissions = new Permissions(illegalConstructorKey);\n\n/** Converts all file URLs in FS allowlists to paths. */\nfunction serializePermissions(permissions) {\n  if (typeof permissions == \"object\" && permissions != null) {\n    const serializedPermissions = { __proto__: null };\n    for (","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/runtime/js/10_permissions.js#L240-L276","documentation":"Deno.permissions.request/requestSync prompt the user (or resolve against flags when prompts are disabled) and validate the descriptor first: a non-null object whose `name` is one of read, write, net, env, sys, run, ffi, import. Otherwise they throw TypeError(`The provided value \"${desc?.name}\" is not a valid permission name.`) — note this variant's message ends with a period; the async request() surfaces it as a rejection.","triggerScenarios":"`Deno.permissions.request({ name: 'network' })`; requesting with a typo like 'writ'; passing a non-object or no descriptor; mapping CLI flag strings directly to descriptor names.","commonSituations":"Interactive CLIs requesting scoped access at runtime; permission prompts in tools run with --no-prompt where a bad name fails fast instead of prompting.","solutions":["Use exactly one of: read, write, net, env, sys, run, ffi, import, with the matching per-name field (path, host, command, variable, kind)","Validate the descriptor before prompting (see defense) so users never see a crash mid-flow","For dynamic names, verify against a const list and surface a configuration error","Catch the rejection from the async form when descriptors are external input"],"exampleFix":"// before\nawait Deno.permissions.request({ name: 'network' });\n\n// after\nawait Deno.permissions.request({ name: 'net', host: 'api.example.com' });","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 Error('invalid permission request');\n}\nconst status = await Deno.permissions.request(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":"try {\n  const status = await Deno.permissions.request(desc);\n} catch (e) {\n  if (e instanceof TypeError && e.message.includes('not a valid permission name')) {\n    // bad descriptor — surface a configuration error to the user\n  } else {\n    throw e;\n  }\n}","preventionTips":["Validate names before prompting so users never hit a crash mid-prompt","Remember this variant's message ends with a period — match loosely (includes) not exactly","request() rejects asynchronously; wrap user-facing flows in try/catch around the await"],"tags":["permissions","typeerror","descriptor","validation","prompt"],"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"}