Skip to content

Fix delete graphrag not take effect in UI#14879

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
wangq8:bugfix/delete-graphrag-not-take-effect
May 13, 2026
Merged

Fix delete graphrag not take effect in UI#14879
wangq8 merged 1 commit into
infiniflow:mainfrom
wangq8:bugfix/delete-graphrag-not-take-effect

Conversation

@wangq8
Copy link
Copy Markdown
Collaborator

@wangq8 wangq8 commented May 13, 2026

What problem does this PR solve?

Fix delete graphrag not take effect in UI

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

@wangq8 wangq8 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels May 13, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The delete_knowledge_graph() method now resets GraphRAG-related task state in the dataset record after clearing artifacts and phase markers. The method calls KnowledgebaseService.update_by_id() to set graphrag_task_id to an empty string and graphrag_task_finish_at to None, ensuring full cleanup of GraphRAG task tracking.

Changes

GraphRAG Knowledge Graph Deletion Cleanup

Layer / File(s) Summary
Reset task state after artifact deletion
api/apps/services/dataset_api_service.py
After clearing GraphRAG phase markers, delete_knowledge_graph() calls KnowledgebaseService.update_by_id() to reset graphrag_task_id to an empty string and graphrag_task_finish_at to None, completing the knowledge graph cleanup.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A knowledge graph removed with care,
Tasks and timestamps scrubbed to air,
State reset clean, no traces stay,
The dataset's ready for a new day! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the bug being fixed: deleting graphrag not taking effect in the UI, which aligns with the actual code change that resets GraphRAG-related task state.
Description check ✅ Passed The PR description includes both required sections from the template: 'What problem does this PR solve?' and 'Type of change' with Bug Fix correctly selected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@wangq8 wangq8 marked this pull request as ready for review May 13, 2026 05:16
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 13, 2026
@wangq8 wangq8 requested a review from euvre May 13, 2026 05:20
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
api/apps/services/dataset_api_service.py (1)

437-460: ⚡ Quick win

Consider adding logging for observability.

The delete_index() function logs its operations (lines 811, 830), but this function has no logging. Adding a log statement would improve debugging and monitoring, especially since this change fixes a UI consistency bug.

📝 Suggested logging addition
 def delete_knowledge_graph(dataset_id: str, tenant_id: str):
     """
     Delete knowledge graph for a dataset.

     :param dataset_id: dataset ID
     :param tenant_id: tenant ID
     :return: (success, result) or (success, error_message)
     """
     if not KnowledgebaseService.accessible(dataset_id, tenant_id):
         return False, "No authorization."
     _, kb = KnowledgebaseService.get_by_id(dataset_id)
+    
+    logging.info("delete_knowledge_graph: dataset=%s tenant=%s", dataset_id, tenant_id)
+    
     from rag.nlp import search
     from rag.graphrag.phase_markers import clear_phase_markers
     settings.docStoreConn.delete({"knowledge_graph_kwd": ["graph", "subgraph", "entity", "relation", "community_report"]},
                                  search.index_name(kb.tenant_id), dataset_id)
     # Wiping the graph invalidates any phase-completion markers used to
     # short-circuit resolution / community detection on resume.
     clear_phase_markers(dataset_id)
     KnowledgebaseService.update_by_id(
         kb.id,
         {"graphrag_task_id": "", "graphrag_task_finish_at": None},
     )
+    logging.info("delete_knowledge_graph: cleared GraphRAG artifacts, phase markers, and task state for dataset=%s", dataset_id)

     return True, True

As per coding guidelines: "Add logging for new flows"

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api/apps/services/dataset_api_service.py` around lines 437 - 460, Add
observability to delete_knowledge_graph by logging key steps and outcomes:
before calling settings.docStoreConn.delete log an info with dataset_id,
tenant_id and kb.id indicating the delete is starting; on successful completion
log an info confirming deletion and that phase markers were cleared and
graphrag_task fields reset; on exceptions around settings.docStoreConn.delete
catch and log an error with the exception and context (dataset_id, tenant_id,
kb.id) and return the existing False,error path. Use the module's existing
logger (e.g., logger.info / logger.error) and reference the function
delete_knowledge_graph, KnowledgebaseService, settings.docStoreConn.delete, and
clear_phase_markers to locate where to add these logs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@api/apps/services/dataset_api_service.py`:
- Around line 437-460: Add observability to delete_knowledge_graph by logging
key steps and outcomes: before calling settings.docStoreConn.delete log an info
with dataset_id, tenant_id and kb.id indicating the delete is starting; on
successful completion log an info confirming deletion and that phase markers
were cleared and graphrag_task fields reset; on exceptions around
settings.docStoreConn.delete catch and log an error with the exception and
context (dataset_id, tenant_id, kb.id) and return the existing False,error path.
Use the module's existing logger (e.g., logger.info / logger.error) and
reference the function delete_knowledge_graph, KnowledgebaseService,
settings.docStoreConn.delete, and clear_phase_markers to locate where to add
these logs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aee9ad94-3659-4c2b-91c1-aaae0526fffb

📥 Commits

Reviewing files that changed from the base of the PR and between 733d75d and 74eea79.

📒 Files selected for processing (1)
  • api/apps/services/dataset_api_service.py

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.16%. Comparing base (5a5e766) to head (74eea79).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14879   +/-   ##
=======================================
  Coverage   94.16%   94.16%           
=======================================
  Files          10       10           
  Lines         703      703           
  Branches      112      112           
=======================================
  Hits          662      662           
  Misses         25       25           
  Partials       16       16           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wangq8 wangq8 merged commit 45d676b into infiniflow:main May 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants