humy2833 / FTP-Simple

visual studio code extension
107 stars 39 forks source link

Cannot read properties of undefined (reading '0') #324

Open marcin1333 opened 4 weeks ago

marcin1333 commented 4 weeks ago

Today I have this error:

[Window Title] Visual Studio Code [Main Instruction] Command 'ftp-simple : Config - FTP connection setting' resulted in an error [Content] Cannot read properties of undefined (reading '0') [OK]

What is happen??

marcin1333 commented 4 weeks ago

Downgrade to VSCodeUserSetup-x64-1.92.2 helps for now

vuhaopro90 commented 4 weeks ago

Yesterday I also encountered the same error while previously using it normally

Codingale commented 4 weeks ago

Same issue here, opened VS code and was greeted with this too, also some misconfigured config.

Full trace:


TypeError: Cannot read properties of undefined (reading '0')
    at isInsideNodeModules (node:internal/util:514:17)
    at showFlaggedDeprecation (node:buffer:178:8)
    at new Buffer (node:buffer:266:3)
    at Crypto.decodeHex (eval at <anonymous> (c:\Users\Codingale\.vscode\extensions\humy2833.ftp-simple-0.7.6\lib\crypto-util.js:1:63), <anonymous>:1:1057)
    at Crypto.encrypt (eval at <anonymous> (c:\Users\Codingale\.vscode\extensions\humy2833.ftp-simple-0.7.6\lib\crypto-util.js:1:63), <anonymous>:1:254)
    at writeConfigFile (c:\Users\Codingale\.vscode\extensions\humy2833.ftp-simple-0.7.6\extension.js:973:50)
    at initConfig (c:\Users\Codingale\.vscode\extensions\humy2833.ftp-simple-0.7.6\extension.js:991:9)
    at c:\Users\Codingale\.vscode\extensions\humy2833.ftp-simple-0.7.6\extension.js:185:21
    at h (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:161:210554)
    at h.$executeContributedCommand (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:161:211414)
    at y.S (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:158:5968)
    at y.Q (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:158:5734)
    at y.M (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:158:4767)
    at y.L (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:158:3602)
    at i.value (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:158:2297)
    at r.B (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:90:732)
    at r.fire (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:90:949)
    at a.fire (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:14463)
    at i.value (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:184:8635)
    at r.B (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:90:732)
    at r.fire (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:90:949)
    at a.fire (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:14463)
    at MessagePortMain.<anonymous> (c:\Users\Codingale\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:184:6761)
    at MessagePortMain.emit (node:events:519:28)
    at Object.MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:2619) ftp.config {"value":"humy2833.ftp-simple","_lower":"humy2833.ftp-simple"}
nazim848 commented 4 weeks ago

Facing the same issue. Any workaround?

brijtherocking commented 4 weeks ago

Facing the same issue as well.

GouRav404 commented 4 weeks ago

https://update.code.visualstudio.com/1.92.2/win32-x64-user/stable

Download from this Link issue Solved there something conflicts with new 1.93.1

yunusga commented 4 weeks ago

https://github.com/yunusga/FTP-Simple/blob/main/ftp-simple-1.0.0-hotfix.vsix hotfix for abandoned super extension

Repo: https://github.com/yunusga/FTP-Simple

Warning

Please send all PR and other stuff to my repository. Because this is a cool plugin and I think it needs to be maintained and updated to a more modern and reliable code + I had more than 40 sites in the config that I lost after updating VS Code)

https://github.com/humy2833/FTP-Simple/issues/321, https://github.com/humy2833/FTP-Simple/issues/322, https://github.com/humy2833/FTP-Simple/issues/323

KnifeLemon commented 4 weeks ago

@yunusga Nice work ❤️

Hakasuro2 commented 4 weeks ago

Thank you! It works. You made me happy ;-)

MUHAMMADIHSANALIKAP commented 4 weeks ago

Excellent, and I am thankful to all of my mates. Love you all, and happy coding. Hopefully, I will be safe soon, and my funds will be transferred. Regards, 😂🇵🇰😂

Thorngage commented 4 weeks ago

https://github.com/yunusga/FTP-Simple/blob/main/ftp-simple-1.0.0-hotfix.vsix hotfix for abandoned super extension

Repo: https://github.com/yunusga/FTP-Simple

Warning

* No encrypt for new configs (need more time)

* New config directory in C:\Users<USERNAME>\AppData\Roaming\Code\User\globalStorage\yunusga.ftp-simple

* Old config directory in C:\Users<USERNAME>\AppData\Roaming\Code\User\globalStorage\humy2833.ftp-simple (encrypted)

* @humy2833 not added licence to repo

Please send all PR and other stuff to my repository. Because this is a cool plugin and I think it needs to be maintained and updated to a more modern and reliable code + I had more than 40 sites in the config that I lost after updating VS Code)

321, #322, #323

Sorry for my incompetence, how do I go to apply this hotfix?

adilhanomeronder commented 3 weeks ago

@yunusga Thanks for hotfix. It's working. ❤️

PetePistolas commented 3 weeks ago

https://github.com/yunusga/FTP-Simple/blob/main/ftp-simple-1.0.0-hotfix.vsix hotfix for abandoned super extension Repo: https://github.com/yunusga/FTP-Simple Warning

* No encrypt for new configs (need more time)

* New config directory in C:\Users<USERNAME>\AppData\Roaming\Code\User\globalStorage\yunusga.ftp-simple

* Old config directory in C:\Users<USERNAME>\AppData\Roaming\Code\User\globalStorage\humy2833.ftp-simple (encrypted)

* @humy2833 not added licence to repo

Please send all PR and other stuff to my repository. Because this is a cool plugin and I think it needs to be maintained and updated to a more modern and reliable code + I had more than 40 sites in the config that I lost after updating VS Code)

321, #322, #323

Sorry for my incompetence, how do I go to apply this hotfix?

Same here... I'am new using github and vscode and I'm a bit lost

Codingale commented 3 weeks ago

To install a VSIX you go to the extensions, and click the three dots and click install from VSIX, and find the extension.

Guide

After install you can copy over the old files from %appdata%\Code\User\globalStorage\humy2833.ftp-simple into %appdata%\Code\User\globalStorage\yunusga.ftp-simple I recommend deleting the old ftp-simple.json or re-naming it for now.

Then you set up your config again with the F1, then FTP-Simple: Config, and all the options like autosave etc you need.

You can download the latest one here: https://github.com/yunusga/FTP-Simple/raw/main/ftp-simple-1.0.2-hotfix.vsix

The other link is a version behind, @yunusga needs to publish instructions in the readme.md, or the extension to the market this probably but there is no license in this repo which be a issue however.

PetePistolas commented 3 weeks ago

To install a VSIX you go to the extensions, and click the three dots and click install from VSIX, and find the extension.

Guide

You can download the latest one here: https://github.com/yunusga/FTP-Simple/raw/main/ftp-simple-1.0.2-hotfix.vsix

The other link is a version behind, @yunusga needs to publish instructions in the readme.md, or the extension to the market this probably but there is no license in this repo which be a issue however.

Really appreciate the answer!

Should I uninstall or disable the other ftp-simple extension?

Thanks in advanced :)

Codingale commented 3 weeks ago

Yes, you should disable it, also you you can move the files in %appdata%\Code\User\globalStorage\humy2833.ftp-simple into %appdata%\Code\User\globalStorage\yunusga.ftp-simple

Then you set up your config again with the F1 > FTP-Simple config, and all the options like autosave etc you need.

PetePistolas commented 3 weeks ago

Yes, you should disable it, also you you can move the files in %appdata%\Code\User\globalStorage\humy2833.ftp-simple into %appdata%\Code\User\globalStorage\yunusga.ftp-simple

Then you set up your config again with the F1 > FTP-Simple config, and all the options like autosave etc you need.

Thank you so much! Back to work again. Reaaly appreciate the help :)

Have a nice day!

Thorngage commented 3 weeks ago

Yes, you should disable it, also you you can move the files in %appdata%\Code\User\globalStorage\humy2833.ftp-simple into %appdata%\Code\User\globalStorage\yunusga.ftp-simple

Then you set up your config again with the F1 > FTP-Simple config, and all the options like autosave etc you need.

To help other users: when you copy these files, be sure to NOT copy (or to delete afterwards) the ftp-simple JSON file, as it will clash with the "new" extension resulting in an error, basically, only copy the remote-workspace-temp folder and its contents

Bricobit commented 3 weeks ago

Thanks for the hotfix, it solved my problem

Shpizzi commented 3 weeks ago

Thanks for the hotfix!

peetcc commented 3 weeks ago

I investigated this today (9 Sept) because I use this extension EVERY DAY, ALL DAY.

After the VSCODE v1.93 upgrade on Friday 6 Sept 2024 a newer version of NodeJS was introduced that causes the error. Some Buffer class involved, whatever.

I managed to fix it for me by editing 2 lines of code in the extension.js file and then I re-created the setup JSON file by hand and it was ok again.

The setup file is encrypted when you save, and decrypted when you run the CONFIG command and see the pure JSON on your screen. On disk it is always encrypted. The crash problem is in the encryption/decryption.

Essentialy removing the encryption/decryption of the settings file made it working again. But then the password is exposed.

That is of course a temporary solution, but I now understand what needs to be done for a permanent fix.

The Changes I made for the temporary fix is:

function writeConfigFile(json) { // fileUtil.writeFileSync(CONFIG_PATH, cryptoUtil.encrypt(JSON.stringify(json, null, '\t'))); // <<<==== CHNANGED THIS LINE TO THE ONE BELOW fileUtil.writeFileSync(CONFIG_PATH, JSON.stringify(json, null, '\t')); fileUtil.rm(CONFIG_PATH_TEMP); } function initConfig() { var result = true; var json = vsUtil.getConfig(CONFIG_NAME); try { // json = cryptoUtil.decrypt(json); // <<<==== COMMENTED OUT THIS LINE json = JSON.parse(json); } catch (e) {

My suggestion going forward is :

  1. Use the secretStorage API for the password (or everything) instead of encrypted JSON files.
  2. Clean up and maybe redesign the code for this extension, the code 'smells'

cheers.

karlosb commented 3 weeks ago

I've followed through @Codingale instructions to get the new hotfix installed... ie. disabled the existing ftp-simple extension, and used 'Install from VSIX' to install the latest ftp-simple-1.0.2-hotfix.vsix release...

... and all works and downloads a live site directory....

However if I resave (ie. simply using keyboard shortcut command+S on mac) a file it does not appear to re-write the modified file back to the FTP server and no mention of it in the 'OUTPUT' window for (with ftp-simple dropdown selected).

A newly created file will can be uploaded (and this is mentioned in the 'OUTPUT' window) but again... if you modify this new file it does not write the changes back to the ftp connected server.

Any ideas what could be wrong with this?

viniciuswebmaster commented 3 weeks ago

I've followed through @Codingale instructions to get the new hotfix installed... ie. disabled the existing ftp-simple extension, and used 'Install from VSIX' to install the latest ftp-simple-1.0.2-hotfix.vsix release...

... and all works and downloads a live site directory....

However if I resave (ie. simply using keyboard shortcut command+S on mac) a file it does not appear to re-write the modified file back to the FTP server and no mention of it in the 'OUTPUT' window for (with ftp-simple dropdown selected).

A newly created file will can be uploaded (and this is mentioned in the 'OUTPUT' window) but again... if you modify this new file it does not write the changes back to the ftp connected server.

Any ideas what could be wrong with this?

I've faced the same issue and I realized that the new default config file doesn't have the

"autosave": true,
"confirm": true

options. I put it in the config file, reopened the VSCode and it worked fine to me!

Hope it helps!

karlosb commented 3 weeks ago

@viniciuswebmaster ah fantastic! Many thanks for this, much appreciated! 😃👍

Gabjosi commented 3 weeks ago

Now a spanish comment.

Gracias, funciono, trabajo con esto, asi que muchas gracias. <3

Yes, you should disable it, also you you can move the files in %appdata%\Code\User\globalStorage\humy2833.ftp-simple into %appdata%\Code\User\globalStorage\yunusga.ftp-simple

Then you set up your config again with the F1 > FTP-Simple config, and all the options like autosave etc you need.

danielsheeper commented 2 weeks ago

it is working but every information is missing after copy and paste. any suggestion?

Gabjosi commented 2 weeks ago

it is working but every information is missing after copy and paste. any suggestion?

It is not lost, you must reconnect with the server. Once you put the correct data in the config to connect to your server. you must download the directory again

Config: [ { "name": "ftp.xxx.cl", "host": "xxx.xxx.xxx.xxx", "port": 21, "type": "ftp", "username": "xxx@yyy.z", "password": "server pass", "path": "/", "autosave": true, "confirm": true } ] The config information is the same as the ftp information you use to connect to your server.

image

berkegulec commented 2 weeks ago

@yunusga thanks my friend <3

evyncke commented 2 weeks ago

And if you want to get back the previous configuration, here is a small Python3 code for doing so

from Crypto.Cipher import AES
import binascii
import os
# The key & IV are from https://raw.githubusercontent.com/humy2833/FTP-Simple/master/lib/crypto-util.js
# unpacked with https://matthewfl.com/unPacker.html
# For some unknown reason, the string are doubled hexified...
key = binascii.unhexlify("3134626336333765663466623436663233346636383438353432623336653463")
key = binascii.unhexlify(key)
IV = binascii.unhexlify("6436346335333638333537633633323763333232633632633961346233653663")
IV = binascii.unhexlify(IV)
# Replace cipherText by the content of ~/Library/Application\ Support/Code/User/globalStorage/humy2833.ftp-simple/ftp-simple.json (on MacOS)
text = binascii.unhexlify(cipherText)
encryptor = AES.new(key, AES.MODE_CBC, IV=IV)
plainText = encryptor.decrypt(text)
print(plainText.decode('utf-8'))
jesussuarz commented 6 days ago

https://github.com/yunusga/FTP-Simple/blob/main/ftp-simple-1.0.0-hotfix.vsix hotfix for abandoned super extension

Repo: https://github.com/yunusga/FTP-Simple

Warning

  • No encrypt for new configs (need more time)
  • New config directory in C:\Users\AppData\Roaming\Code\User\globalStorage\yunusga.ftp-simple
  • Old config directory in C:\Users\AppData\Roaming\Code\User\globalStorage\humy2833.ftp-simple (encrypted)
  • @humy2833 not added licence to repo

Please send all PR and other stuff to my repository. Because this is a cool plugin and I think it needs to be maintained and updated to a more modern and reliable code + I had more than 40 sites in the config that I lost after updating VS Code)

321, #322, #323

This was the solution for me.