sqlite3.ProgrammingError after upgrade to 4.1 from 3.x

Mads Kiilerich mads at kiilerich.com
Wed Jul 31 12:00:10 UTC 2019


On 7/31/19 11:37 AM, Carl Boberg wrote:
> Hi list!
>
> We have been using kallithea for quite a while now and are very happy 
> with it. But recently I have upgraded our two instances from 3.x to 4.1.


Latest sqlite version is 3.29.0 .

Latest Kallithea version is 0.4.1 . Is that the version you are using?


> Upgrade went fine and all seems to work ok except fort this;
> We have our users in Active Directory (server 2012) and for those 
> users with non ascii chars in their name (åäö in our case since we are 
> in Sweden) this happens when they try to login:
>
> 2019-07-30 16:02:55.021 ERROR [kallithea.model.user] Traceback (most 
> recent call last):
>   File 
> "/opt/kallithea/.local/lib/python2.7/site-packages/kallithea/model/user.py", 
> line 169, in create_or_update
>     Session().flush() # make database assign new_user.user_id
> ...
>   File 
> "/opt/kallithea/.local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", 
> line 536, in do_execute
>     cursor.execute(statement, parameters)
> ProgrammingError: (sqlite3.ProgrammingError) You must not use 8-bit 
> bytestrings unless you use a text_factory that can interpret 8-bit 
> bytestrings (like text_factory = str). It is highly recommended that 
> you instead just switch your application to Unicode strings. [SQL: 
> u'INSERT INTO users (username, password, active, admin, firstname, 
> lastname, email, last_login, extern_type, extern_name, api_key, 
> inherit_default_permissions, created_on, user_data) VALUES (?, ?, ?, 
> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'] [parameters: (u'omannen', 
> '*masked*', 0, 0, u'\xf6mannen', u'man', 'omannen@*masked*', None, 
> 'ldap', 'CN=\xc3\xb6mannen man,OU=*masked*', '*masked*', 1, 
> '2019-07-30 16:02:55.016018', None)] (Background on this error at: 
> http://sqlalche.me/e/f405)
>
> This is an example with a test user called "Ömannen man". It worked 
> fine before upgrade and i I rename the user in AD to not have any ÅÄÖ 
> login works...


That seems to be because you have also have non-ascii characters in the 
LDAP CN. That was not expected.

You can probably fix it by changing your 
https://kallithea-scm.org/repos/kallithea/files/0.4.1/kallithea/model/user.py#L148 
to use "safe_unicode" instead of "safe_str". Can you confirm that works 
for you?

/Mads

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sfconservancy.org/pipermail/kallithea-general/attachments/20190731/8b03ea01/attachment.html>


More information about the kallithea-general mailing list