{"record":{"id":"cecac2e312c086c7","repo":"denoland/deno","slug":"failed-to-execute-query-on-permissions-descri","errorCode":null,"errorMessage":"Failed to execute 'query' on 'Permissions': descriptor required","messagePattern":"Failed to execute 'query' on 'Permissions': descriptor required","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"cli/rt/desktop.rs","lineNumber":655,"sourceCode":"    set onchange(v) { this.#onchange = typeof v === \"function\" ? v : null; }\n  }\n\n  function laufeyToPermissionsApiState(s) {\n    // Spec maps \"prompt\" through verbatim; \"unsupported\" has no spec\n    // analog so we return \"denied\" — query() shouldn't throw, but we\n    // shouldn't lie and say \"granted\" either.\n    switch (s) {\n      case \"granted\": return \"granted\";\n      case \"denied\": return \"denied\";\n      case \"prompt\": return \"prompt\";\n      default: return \"denied\";\n    }\n  }\n\n  const permissionsImpl = {\n    async query(descriptor) {\n      if (descriptor == null || typeof descriptor !== \"object\") {\n        throw new TypeError(\n          \"Failed to execute 'query' on 'Permissions': descriptor required\",\n        );\n      }\n      const name = String(descriptor.name);\n      if (name === \"notifications\") {\n        // No side effects per spec — never call request_*.\n        const s = await op_desktop_query_notification_permission();\n        // Keep Notification.permission's cache in sync: a permissions.query\n        // result is authoritative and lets the synchronous getter report\n        // a current value without us needing a second roundtrip.\n        if (s !== \"unsupported\") {\n          cachedNotificationPermission = laufeyToNotificationPermission(s);\n        }\n        return new PermissionStatus(name, laufeyToPermissionsApiState(s));\n      }\n      // Unknown / unrouted name. Chrome returns \"denied\" for descriptors\n      // it doesn't recognize; mimic that rather than throwing.\n      return new PermissionStatus(name, \"denied\");","sourceCodeStart":637,"sourceCodeEnd":673,"githubUrl":"https://github.com/denoland/deno/blob/f7822238cab635a3a19f99f493f675fa81a7f9d8/cli/rt/desktop.rs#L637-L673","documentation":"The desktop runtime provides a Permissions implementation whose query() supports the 'notifications' permission. Following the Permissions API, the descriptor must be a non-null object; anything else throws a TypeError with the standard \"Failed to execute 'query' on 'Permissions'\" prefix.","triggerScenarios":"`permissions.query()` with no argument; `permissions.query(null)`; passing a bare string `permissions.query(\"notifications\")` instead of the object `{ name: \"notifications\" }`.","commonSituations":"Refactoring from a custom permissions helper that accepted strings; copying browser code that queries multiple permissions; forgetting the descriptor wrapper in TypeScript where the type was loosened to any.","solutions":["Pass a descriptor object: `await navigator.permissions.query({ name: \"notifications\" })`","Guard the call: only invoke query when the descriptor is a non-null object with a string name","Remember only the 'notifications' name is meaningful in this runtime"],"exampleFix":"// before\nconst s = await navigator.permissions.query(\"notifications\");\n\n// after\nconst s = await navigator.permissions.query({ name: \"notifications\" });","handlingStrategy":"type-guard","validationCode":"if (descriptor == null || typeof descriptor !== \"object\") {\n  throw new TypeError(\"descriptor required\");\n}","typeGuard":"function isPermissionDescriptor(d: unknown): d is { name: string } {\n  return typeof d === \"object\" && d !== null &&\n    typeof (d as { name?: unknown }).name === \"string\";\n}","tryCatchPattern":null,"preventionTips":["Always pass a descriptor object: query({ name: 'notifications' })","Type query inputs as PermissionDescriptor so the compiler rejects strings","Remember only the 'notifications' name is meaningful in the desktop runtime"],"tags":["permissions","notifications","desktop","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"f7822238cab635a3a19f99f493f675fa81a7f9d8","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}