Hi,

PFA patch to fix the issue where we were getting exception ValueError: IV
must be 16 bytes long while decrypting the password.
RM#2765

Steps to re-produce:
1) Create new server using pgpass file, do not enter anything in password
field.
2) Connect to server & open query tool (to make one or more connection with
server)
3) Stop pgAdmin4 server from backend & start it again
4) Hard refresh the browser by removing the cache & cookies.
5) Expand the Server-Group in which you added that server, Check the
console you will see the same error, this happens when we try to
automatically restore the server connection while expanding the server
nodes and that server connection do not have any password stored.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py 
b/web/pgadmin/utils/driver/psycopg2/__init__.py
index 689ad76..9459ad0 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -1653,10 +1653,14 @@ class ServerManager(object):
 
         res = dict()
         res['sid'] = self.sid
-        if hasattr(self.password, 'decode'):
-            res['password'] = self.password.decode('utf-8')
+        if hasattr(self, 'password') and self.password:
+            # If running under PY2
+            if hasattr(self.password, 'decode'):
+                res['password'] = self.password.decode('utf-8')
+            else:
+                res['password'] = str(self.password)
         else:
-            res['password'] = str(self.password)
+            res['password'] = self.password
 
         connections = res['connections'] = dict()
 

Reply via email to