Bug report #13683

DBManager doesn't work with the new authentication system

Added by Jérôme Guélat about 4 years ago. Updated almost 4 years ago.

Status:Closed
Priority:High
Assignee:Larry Shaffer
Category:Authentication system
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:21714

Description

DBManager can't connect to a PostGIS database using the new authentication system...

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 31: ordinal not in range(128)
Traceback (most recent call last):
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_model.py", line 422, in rowCount
self._refreshIndex(parent, True)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_model.py", line 473, in refreshIndex
if item.populate():
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_model.py", line 158, in populate
if not connection.connect():
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 98, in connect
return self.connectToUri(uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\plugin.py", line 102, in connectToUri
self.db = self.databasesFactory(self, uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 68, in databasesFactory
return PGDatabase(connection, uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 106, in init
Database.
_init__(self, connection, uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\plugin.py", line 211, in init
self.connector = self.connectorsFactory(uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 109, in connectorsFactory
return PostGisDBConnector(uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\connector.py", line 57, in init
err = unicode(e)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 31: ordinal not in range(128)

Python version: 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]
QGIS version: 2.12.0-Lyon Lyon, cd9d645


Related issues

Duplicated by QGIS Application - Bug report #13841: DbManager does not use the new authentication system Closed 2015-11-16

History

#1 Updated by Saber Razmjooei about 4 years ago

  • Category set to Authentication system

#2 Updated by Larry Shaffer about 4 years ago

  • Assignee set to Larry Shaffer
  • Target version set to Future Release - High Priority

#3 Updated by Larry Shaffer about 4 years ago

Hi,

I can not replicate any problems with using the auth system with DB Manager here. Seems your version of Python has the new error support, which means DB Manager needs updated.

File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\connector.py", line 57, in init
err = unicode(e)

Change that line to just:

err = e

and re-lanuch QGIS and see if DB Manager gives you a useful error (instead of just an error about the error).

#4 Updated by Jérôme Guélat about 4 years ago

Hi and thanks for having a look at this problem. I currently have 2 PostGIS connections, one with the old authentication system and one with the new system (using basic authentication). I can open the first connection without any problem in DBManager, but trying to open the second one freezes QGIS during 3-5 seconds and I get an error message. Here's what I get after changing err = unicode(e) to err = e:

TypeError: QgsCredentials.get(QString, QString, QString, QString message=QString.null) -> (bool, QString, QString): argument 4 has unexpected type 'OperationalError'
Traceback (most recent call last):
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_model.py", line 422, in rowCount
self._refreshIndex(parent, True)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_model.py", line 473, in refreshIndex
if item.populate():
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_model.py", line 158, in populate
if not connection.connect():
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 98, in connect
return self.connectToUri(uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\plugin.py", line 102, in connectToUri
self.db = self.databasesFactory(self, uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 68, in databasesFactory
return PGDatabase(connection, uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 106, in init
Database.
_init__(self, connection, uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\plugin.py", line 211, in init
self.connector = self.connectorsFactory(uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 109, in connectorsFactory
return PostGisDBConnector(uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\connector.py", line 62, in init
(ok, username, password) = QgsCredentials.instance().get(conninfo, username, password, err)
TypeError: QgsCredentials.get(QString, QString, QString, QString message=QString.null) -> (bool, QString, QString): argument 4 has unexpected type 'OperationalError'

Thanks for your help!

#5 Updated by Kirill Krasnoschekov about 4 years ago

Hi, I can confirm this bug.

Connection seems to work (when I create connection in "Add PostGIS Table(s)" dialog and run test, the test passes; I can load tables from this DB into project without DBManager), but when I try to open this DB in DBManager, I get the same error message.
There's one difference: old authentication doesn't work for me.

TypeError: QgsCredentials.get(QString, QString, QString, QString message=QString.null) -> (bool, QString, QString): argument 4 has unexpected type 'OperationalError' 
Traceback (most recent call last):
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_model.py", line 422, in rowCount
    self._refreshIndex(parent, True)
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_model.py", line 473, in _refreshIndex
    if item.populate():
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_model.py", line 158, in populate
    if not connection.connect():
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 98, in connect
    return self.connectToUri(uri)
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\plugin.py", line 102, in connectToUri
    self.db = self.databasesFactory(self, uri)
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 68, in databasesFactory
    return PGDatabase(connection, uri)
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 106, in __init__
    Database.__init__(self, connection, uri)
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\plugin.py", line 211, in __init__
    self.connector = self.connectorsFactory(uri)
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\plugin.py", line 109, in connectorsFactory
    return PostGisDBConnector(uri)
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\\db_manager\\db_plugins\\postgis\\connector.py", line 62, in __init__
    (ok, username, password) = QgsCredentials.instance().get(conninfo, username, password, err)
TypeError: QgsCredentials.get(QString, QString, QString, QString message=QString.null) -> (bool, QString, QString): argument 4 has unexpected type 'OperationalError'

Python version: 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] 
QGIS version: 2.12.0-Lyon Lyon, cd9d645 

#6 Updated by Sebastian Dietrich almost 4 years ago

See #13841, which is a duplicate of this bug? There is a patch (PR 2473) supplied there.

#7 Updated by Alexander Bruy almost 4 years ago

  • Resolution set to fixed/implemented
  • Status changed from Open to Closed

Corresponding PR merged. Reopen is necessary

Also available in: Atom PDF