writer
writer copied to clipboard
Cannot destructure property 'requiresAuth' of '(intermediate value)' as it is undefined
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
.
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
anddata
are always returned. - Or add an extra
|| {}
when destructuring properties frome?.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);
I am also running into this bug.
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.
I am facing the same issue. What should I do!?