mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-30 09:40:35 +02:00
Fix slack error logging (#1800)
This commit is contained in:
parent
08c6e821e7
commit
3e645a510e
@ -12,6 +12,7 @@ from danswer.connectors.gmail.constants import (
|
|||||||
from danswer.connectors.google_drive.constants import (
|
from danswer.connectors.google_drive.constants import (
|
||||||
DB_CREDENTIALS_DICT_SERVICE_ACCOUNT_KEY,
|
DB_CREDENTIALS_DICT_SERVICE_ACCOUNT_KEY,
|
||||||
)
|
)
|
||||||
|
from danswer.db.models import ConnectorCredentialPair
|
||||||
from danswer.db.models import Credential
|
from danswer.db.models import Credential
|
||||||
from danswer.db.models import User
|
from danswer.db.models import User
|
||||||
from danswer.server.documents.models import CredentialBase
|
from danswer.server.documents.models import CredentialBase
|
||||||
@ -142,6 +143,18 @@ def delete_credential(
|
|||||||
f"Credential by provided id {credential_id} does not exist or does not belong to user"
|
f"Credential by provided id {credential_id} does not exist or does not belong to user"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
associated_connectors = (
|
||||||
|
db_session.query(ConnectorCredentialPair)
|
||||||
|
.filter(ConnectorCredentialPair.credential_id == credential_id)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
|
||||||
|
if associated_connectors:
|
||||||
|
raise ValueError(
|
||||||
|
f"Cannot delete credential {credential_id} as it is still associated with {len(associated_connectors)} connector(s). "
|
||||||
|
"Please delete all associated connectors first."
|
||||||
|
)
|
||||||
|
|
||||||
db_session.delete(credential)
|
db_session.delete(credential)
|
||||||
db_session.commit()
|
db_session.commit()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user