refactor: Ingest flow cleanup & Fix ingest duplication streamline investigation URL handling#1191
Conversation
Greptile SummaryThis PR extracts the two-step ingest flow (create investigation → attach URL) from
Confidence Score: 4/5Safe to merge after fixing the incorrect test assertion in the failure path. One P1 in the test suite: the failure-path test asserts tests/utils/test_ingest_delivery.py — Important Files Changed
Sequence DiagramsequenceDiagram
participant GR as generate_report()
participant H as create_investigation_and_attach_url()
participant SI as send_ingest()
participant GU as get_investigation_url()
GR->>H: state, slack_message, summary
H->>SI: state_with_report (report_md)
SI-->>H: investigation_id (str | None)
H->>GU: org_slug, investigation_id
GU-->>H: investigation_url (always str)
alt investigation_id is not None
H->>SI: state_with_url (report_md + investigation_url)
SI-->>H: (ignored)
end
H-->>GR: (investigation_id, investigation_url)
Reviews (1): Last reviewed commit: "refactor: streamline investigation URL h..." | Re-trigger Greptile |
|
@muddlebee @yashksaini-coder @VaibhavUpreti please review. |
|
@SB2318 with so many new PRs it's difficult to track the older review again and newer round of review again. It's not really ideal. If you are having issues with rebase etc I would suggest to explore/learn and practice on a demo PR in your fork. If that helps. Otherwise it's very difficult to keep track of your changes across different PRs. |
okay, let me mention the previous PR name. PR #1086 Actually, I am using github desktop to squash all commit, but somehow they don't allow me to squash merge commits, but I have to update the branch also. That's why I have to create so many PRs |
|
You don't have to squash merge commits. You just rebase if needed for merge conflicts that's it. |
|
Unless there's a merge conflict, you don't have to squash or rebase? Why you doing it over again? |
I have to update branch. and beside this there are also so many commits more than 17 sometimes |
|
That's not the way to do. I will suggest you to go through best git/PR practices and how to do it. And going forward such multiple PRs won't be acceptable. It creates friction for us maintainers. Thank you for understanding. |
Okay, I will try from the next time. 😇 Thanks for considering. 🙏 |
|
🤖 CI passed. Linter didn't scream. Reviewer typed LGTM. @SB2318, every machine in this pipeline just slow-clapped. 🖥️✨ 👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome. |

Fixes #867
Followed by PR #1086
Describe the changes you have made in this PR -
This PR refactors the ingest logic in generate_report() by extracting the two-step flow (create investigation → attach URL) into a dedicated helper.
Previously, generate_report() directly called send_ingest() twice, which made the write path harder to follow and test. This change introduces a single helper that encapsulates that flow without modifying the existing API contract
Key Changes
✔ generate_report() no longer has duplicate ingest logic
✔ Helper encapsulates the two-step flow clearly
✔ No change to send_ingest() contract
✔ Failure behavior unchanged
Updated this PR to address all review comments and CI issues:
Changes made
Fixed
investigation_urlfallback regression by always computing:get_investigation_url(state.get("organization_slug"), investigation_id)inside
create_investigation_and_attach_url()even when ingest fails.This preserves previous behavior:
Updated helper return contract:
investigation_id:str | Noneinvestigation_url: alwaysstrRemoved
investigation_url or ""frombuild_action_blocks()call site since Slack Block Kit rejects empty URL strings.Refactored
test_node.pyto patchcreate_investigation_and_attach_url()directly instead of patching helper internals (send_ingest/get_investigation_url), aligning with integration-level test strategy.Added/updated corresponding tests for helper behavior and fallback URL scenarios.
Refactor summary
✔
generate_report()no longer has duplicate ingest logic✔ Helper encapsulates the two-step ingest flow clearly
✔ No change to
send_ingest()contract✔ Failure behavior unchanged
Ran locally:
Please let me know if any further changes are needed.
Demo/Screenshot for feature changes and bug fixes -
Code Understanding and AI Usage
Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?
If you used AI assistance:
Explain your implementation approach:
What this solves:
Implementation approach:
Ingest Flow Refactor
create_investigation_and_attach_url()send_ingest)investigation_url(conditional second call)generate_report()Key design choices:
send_ingest()unchanged (no API contract changes)Behavior guarantees:
Test coverage:
Checklist before requesting a review
Note: Please check Allow edits from maintainers if you would like us to assist in the PR.