writer icon indicating copy to clipboard operation
writer copied to clipboard

Cannot destructure property 'requiresAuth' of '(intermediate value)' as it is undefined

Open zhuanyan-wang opened this issue 2 years ago • 3 comments

Not sure if this is an isolated case, but recently I found that Mintlify Doc Writer extension no longer works in VS Code due to cannot destructure property 'requiresAuth' of '(intermediate value)' as it is undefined.

Screenshot 2023-02-21 at 12 04 12

Expected Behavior

  • Generated comments and annotations should show up after generating documentation is done.
  • If login is required or an error is encountered, users should be informed.

Current Behavior

  • Nothing happened after generating documentation is finished.
  • Go to Extensions > Mintlify > Runtime Status, it shows cannot destructure property 'requiresAuth' of '(intermediate value)' as it is undefined.

Context (Environment)

  • Mintlify v2.2.1
  • Visual Studio Code
    • Version: 1.75.1 (Universal)
    • Commit: 441438abd1ac652551dbe4d408dfcec8a499b8bf
    • Date: 2023-02-08T21:34:59.000Z (1 wk ago)
    • Electron: 19.1.9
    • Chromium: 102.0.5005.194
    • Node.js: 16.14.2
    • V8: 10.2.154.23-electron.0
    • OS: Darwin x64 22.3.0
    • Sandboxed: No
  • macOS Ventura 13.2.1 (22D68)

Possible Solution

  • Ensure response and data are always returned.
  • Or add an extra || {} when destructuring properties from e?.response?.data during "generating documentation".

Detailed Description

During t.window.withProgress "generating documentation", if an error is caught, it will attempt to extract properties like requiresAuth from e.response.data using destructuring assignment:

const {
  requiresAuth: o,
  requiresUpgrade: n,
  message: s,
  button: i,
} = e?.response?.data;
if (o) return void (0, a.displaySignInView)(s, i);

Cannot destructure property 'requiresAuth' of '(intermediate value)' is thrown if response or data is null or undefined.

It should work after you changed the code to:

const {
  requiresAuth: o,
  requiresUpgrade: n,
  message: s,
  button: i,
} = e?.response?.data || {};
if (o) return void (0, a.displaySignInView)(s, i);

zhuanyan-wang avatar Feb 21 '23 11:02 zhuanyan-wang

I am also running into this bug.

kbader-godaddy avatar Apr 04 '23 20:04 kbader-godaddy

Same here, seemed kind of random as well since I wasn't really running any all to large bits of code through it. Took multiple reinstalls of the extension to get rid of the error and get the extension working again for some reason.

JesseKoldewijn avatar Apr 05 '23 06:04 JesseKoldewijn

I am facing the same issue. What should I do!?

SR-Spoorthi avatar Oct 27 '23 14:10 SR-Spoorthi