Closed BangyuXing closed 4 years ago
Thanks @BangyuXing for reporting this issue.
The problem seems to be that the string "!" is transformed to an empty string at some point along the way, which then violates a database constraint.
We should really add some basic sanity checks of strings for user names etc. at the click
level
Note to self:
After encountering this issue in the tutorial, verdi quicksetup
was broken for some reason, even when using sensible values for the input.
The reason seemed to be that it was trying to use a combination of database user and password that was not accepted by the postgresql server.
Forcing to use the same --db-user --db-password as the generic
profile resolved the issue.
Just encountered another instance, where a sanity check on input variables would be useful:
When using yaml config files, you can put comments, e.g.
host_name: 123.123.123.123 # IP address
and we use this in the tutorial to let people what the values mean and where to replace things.
However, this is only considered a comment, when there is a space before the hash, i.e. the following is not a comment:
host_name: 123.123.123.123# IP address
A basic validation of the IP address would have caught this.
And another one, where it seems leaving the hostname
for the postgres DB empty resulted in "NoneNone" ending up as the hostname in psycopg2.
return self.dbapi.connect(*cargs, **cparams)
File "/home/tco/.virtualenvs/aiida/lib/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "NoneNone" to address: Name or service not known
File "/home/tco/.virtualenvs/aiida/lib/python3.6/site-packages/aiida/cmdline/commands/cmd_setup.py", line 90, in setup
email=email, first_name=first_name, last_name=last_name, institution=institution
File "/home/tco/.virtualenvs/aiida/lib/python3.6/site-packages/aiida/orm/users.py", line 47, in get_or_create
return False, self.get(email=email)
File "/home/tco/.virtualenvs/aiida/lib/python3.6/site-packages/aiida/orm/entities.py", line 120, in get
res = self.find(filters=filters)
File "/home/tco/.virtualenvs/aiida/lib/python3.6/site-packages/aiida/orm/entities.py", line 154, in find
return [[0] for in query.all()]
File "/home/tco/.virtualenvs/aiida/lib/python3.6/site-packages/aiida/orm/querybuilder.py", line 2204, in all
return list(self.iterall(batch_size=batch_size))
File "/home/tco/.virtualenvs/aiida/lib/python3.6/site-packages/aiida/orm/querybuilder.py", line 2161, in iterall
for item in self._impl.iterall(query, batch_size, self._attrkeys_as_in_sql_result):
File "/home/tco/.virtualenvs/aiida/lib/python3.6/site-packages/aiida/orm/implementation/django/querybuilder.py", line 450, in iterall
for rowitem in results:
File "/home/tco/.virtualenvs/aiida/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3317, in __iter__
I tried to set up a new profile. Because of some misunderstanding, I entered "!" for "First name", "Last name" and "Institution", and encountered this error.