Skip to content

bug: credential orphaning during knowledge graph cascade deletion #315

@jsell-rh

Description

@jsell-rh

Summary

When a knowledge graph is deleted, its data sources are cascade-deleted via KnowledgeGraphService.delete(). However, the service calls ds_repo.delete(ds) directly on each data source, which does not delete the associated encrypted credentials from the secret store. Only DataSourceService.delete() handles credential cleanup.

Expected Behavior

Per specs/management/data-sources.spec.md and specs/management/knowledge-graphs.spec.md:

  • When a knowledge graph is deleted, all data sources within it are deleted including their credentials
  • Encrypted credentials should be deleted from the secret store before the data source record is removed

Actual Behavior

KnowledgeGraphService.delete() at management/application/services/knowledge_graph_service.py:368-374 calls ds_repo.delete(ds) which only deletes the database record. The FernetSecretStore entry at datasource/{id}/credentials is left orphaned in the encrypted_credentials table.

Impact

Orphaned encrypted credential blobs accumulate in the database over time. While they are inert (no data source references them), they represent a data hygiene issue and potential compliance concern — encrypted secrets should be deleted when their parent resource is deleted.

Fix

KnowledgeGraphService.delete() should delete credentials via the secret store before deleting each data source, mirroring what DataSourceService.delete() does at lines 385-389.

References

  • specs/management/knowledge-graphs.spec.md — "all data sources within it are deleted first (including their credentials)"
  • specs/management/data-sources.spec.md — "the encrypted credentials are deleted first"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions