You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the latest alembic with the latest sqlalchemy migrations fail with an AttributeError: can't set attribute
I recently updated dependencies (alembic==1.5.7 and sqlalchemy==1.4.2). When running an alembic command in some environments, you get the following error: AttributeError: can't set attribute (full stack trace below). I believe (looking at the stacktrace below) that this is due to the fact that in sqlalchemy 1.4, they made the URL object immutable and the function that's causing the error (obfuscate_url_pw) is clearly trying to set an attribute on the returned (now immutable) object.
Expected behavior
Passwords are obfuscated but are done so in a way that plays well with the now-immutable URL object in sqlalchemy>=1.4.
To Reproduce
I've not been able to reproduce this outside of our CI/CD environment, even though we run it within the same docker container. I'll try to get some time to find the path that triggers the obfuscation of passwords based on the stack trace below, but here's our general setup:
pipenv to manage dependencies
alembic==1.5.7
sqlalchemy==1.4.2
SQL Server odbc driver (we use a custom pip package for this and custom docker layers, so I'll have to unwind those or see if I can repro with a simpler db-setup).
I was mostly trying the current alembic command, but it seems to be happening on other alembic commands as well.
Error
Traceback (most recent call last):
File "/usr/local/bin/alembic", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 559, in main
CommandLine(prog=prog).main(argv=argv)
File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 553, in main
self.run_cmd(cfg, options)
File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 530, in run_cmd
fn(
File "/usr/local/lib/python3.9/site-packages/alembic/command.py", line 506, in current
script.run_env()
File "/usr/local/lib/python3.9/site-packages/alembic/script/base.py", line 490, in run_env
util.load_python_file(self.dir, "env.py")
File "/usr/local/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 97, in load_python_file
module = load_module_py(module_id, path)
File "/usr/local/lib/python3.9/site-packages/alembic/util/compat.py", line 182, in load_module_py
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "./env.py", line 58, in <module>
run_migrations_online()
File "./env.py", line 51, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/usr/local/lib/python3.9/site-packages/alembic/runtime/environment.py", line 813, in run_migrations
self.get_context().run_migrations(**kw)
File "/usr/local/lib/python3.9/site-packages/alembic/runtime/migration.py", line 548, in run_migrations
for step in self._migrations_fn(heads, self):
File "/usr/local/lib/python3.9/site-packages/alembic/command.py", line 496, in display_version
util.obfuscate_url_pw(context.connection.engine.url),
File "/usr/local/lib/python3.9/site-packages/alembic/util/messaging.py", line 67, in obfuscate_url_pw
u.password = "XXXXX"
AttributeError: can't set attribute
Versions.
OS: Docker image, base is python:3.9.0-slim-buster
Python: (3.9.0)
Alembic: 1.5.7
SQLAlchemy: 1.4.2
Database: SQL Server
DBAPI: pyodbc==4.0.28
The text was updated successfully, but these errors were encountered:
When using the latest alembic with the latest sqlalchemy migrations fail with an AttributeError: can't set attribute
I recently updated dependencies (alembic==1.5.7 and sqlalchemy==1.4.2). When running an alembic command in some environments, you get the following error:
AttributeError: can't set attribute
(full stack trace below). I believe (looking at the stacktrace below) that this is due to the fact that in sqlalchemy 1.4, they made the URL object immutable and the function that's causing the error (obfuscate_url_pw) is clearly trying to set an attribute on the returned (now immutable) object.Expected behavior
Passwords are obfuscated but are done so in a way that plays well with the now-immutable URL object in sqlalchemy>=1.4.
To Reproduce
I've not been able to reproduce this outside of our CI/CD environment, even though we run it within the same docker container. I'll try to get some time to find the path that triggers the obfuscation of passwords based on the stack trace below, but here's our general setup:
I was mostly trying the
current
alembic command, but it seems to be happening on other alembic commands as well.Error
Versions.
python:3.9.0-slim-buster
The text was updated successfully, but these errors were encountered: