herlambang opened a new issue, #30984:
URL: https://github.com/apache/airflow/issues/30984
### Apache Airflow version
2.6.0
### What happened
Hi, I'm unable to remove DagRun and TaskInstance when they have note
attached.
### What you think should happen instead
Should be able to remove DagRuns or TaskInstances with or without notes.
Also note should be removed when parent entity is removed.
### How to reproduce
1. Create note in DagRun or TaskInstance
2. Try to remove the row that note has been added by clicking delete record
icon. This will display alert in the UI `General Error <class 'AssertionError'>`
3. Select checkbox DagRun containing note, click `Actions` dropdown and
select `Delete`. This won't display anything in the UI.
### Operating System
OSX 12.6
### Versions of Apache Airflow Providers
apache-airflow-providers-cncf-kubernetes==5.2.2
apache-airflow-providers-common-sql==1.3.4
apache-airflow-providers-ftp==3.3.1
apache-airflow-providers-http==4.2.0
apache-airflow-providers-imap==3.1.1
apache-airflow-providers-postgres==5.4.0
apache-airflow-providers-sqlite==3.3.1
### Deployment
Virtualenv installation
### Deployment details
Deployed using Postgresql 13.9 and sqlite 3
### Anything else
DagRun deletion Log
```
[2023-05-01T13:06:42.125+0700] {interface.py:790} ERROR - Delete record
error: Dependency rule tried to blank-out primary key column
'dag_run_note.dag_run_id' on instance '<DagRunNote at 0x1125afa00>'
Traceback (most recent call last):
File
"/opt/airflow/.venv/lib/python3.10/site-packages/flask_appbuilder/models/sqla/interface.py",
line 775, in delete
self.session.commit()
File "<string>", line 2, in commit
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 1451, in commit
self._transaction.commit(_to_root=self.future)
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 829, in commit
self._prepare_impl()
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 808, in _prepare_impl
self.session.flush()
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 3446, in flush
self._flush(objects)
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 3585, in _flush
with util.safe_reraise():
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py",
line 70, in __exit__
compat.raise_(
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py",
line 211, in raise_
raise exception
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 3546, in _flush
flush_context.execute()
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py",
line 456, in execute
rec.execute(self)
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py",
line 577, in execute
self.dependency_processor.process_deletes(uow, states)
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/dependency.py",
line 552, in process_deletes
self._synchronize(
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/dependency.py",
line 610, in _synchronize
sync.clear(dest, self.mapper, self.prop.synchronize_pairs)
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/sync.py", line
86, in clear
raise AssertionError(
AssertionError: Dependency rule tried to blank-out primary key column
'dag_run_note.dag_run_id' on instance '<DagRunNote at 0x1125afa00>'
```
TaskInstance deletion Log
```
[2023-05-01T13:06:42.125+0700] {interface.py:790} ERROR - Delete record
error: Dependency rule tried to blank-out primary key column
'task_instance_note.task_id' on instance '<TaskInstanceNote at 0x1126ba770>'
Traceback (most recent call last):
File
"/opt/airflow/.venv/lib/python3.10/site-packages/flask_appbuilder/models/sqla/interface.py",
line 775, in delete
self.session.commit()
File "<string>", line 2, in commit
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 1451, in commit
self._transaction.commit(_to_root=self.future)
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 829, in commit
self._prepare_impl()
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 808, in _prepare_impl
self.session.flush()
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 3446, in flush
self._flush(objects)
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 3585, in _flush
with util.safe_reraise():
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py",
line 70, in __exit__
compat.raise_(
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py",
line 211, in raise_
raise exception
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py",
line 3546, in _flush
flush_context.execute()
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py",
line 456, in execute
rec.execute(self)
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py",
line 577, in execute
self.dependency_processor.process_deletes(uow, states)
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/dependency.py",
line 552, in process_deletes
self._synchronize(
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/dependency.py",
line 610, in _synchronize
sync.clear(dest, self.mapper, self.prop.synchronize_pairs)
File
"/opt/airflow/.venv/lib/python3.10/site-packages/sqlalchemy/orm/sync.py", line
86, in clear
raise AssertionError(
AssertionError: Dependency rule tried to blank-out primary key column
'task_instance_note.task_id' on instance '<TaskInstanceNote at 0x1126ba770>'
```
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]