Ingest flow cleanup: Fix ingest duplication#1086
Ingest flow cleanup: Fix ingest duplication#1086SB2318 wants to merge 17 commits intoTracer-Cloud:mainfrom
Conversation
Greptile SummaryThis PR extracts the two-step ingest flow (create investigation → attach URL) from Confidence Score: 5/5Safe to merge — pure refactoring with no behavioral changes; all findings are P2 style/cleanup items. All issues found are P2: a cross-layer import that doesn't cause a runtime problem, missing tests that were claimed but not blocking the refactored logic (existing behavior is unchanged), and a stale comment. No functional regressions introduced. app/utils/ingest_delivery.py — cross-layer import from app/nodes/ and missing tests for the new helper. Important Files Changed
Sequence DiagramsequenceDiagram
participant N as node.py generate_report()
participant H as ingest_delivery.py create_investigation_and_attach_url()
participant S as send_ingest()
participant API as Ingest API
N->>H: create_investigation_and_attach_url(state, slack_message, summary)
H->>S: send_ingest(state_with_report)
S->>API: POST /api/investigations/ingest
API-->>S: { data: { investigation_id } }
S-->>H: investigation_id
H->>H: get_investigation_url(org_slug, investigation_id)
alt investigation_id present
H->>S: send_ingest(state_with_url)
S->>API: POST /api/investigations/ingest (with investigation_url)
API-->>S: 200 OK
S-->>H: ignored
end
H-->>N: (investigation_id, investigation_url)
Reviews (1): Last reviewed commit: "Merge branch 'Tracer-Cloud:main' into co..." | Re-trigger Greptile |
|
Hey @SB2318, this is a clean refactor — moving One small thing I noticed in the new investigation_id, investigation_url = (
ingest_delivery.create_investigation_and_attach_url(sample_state, "slack message")
)It returns a tuple of Also just noticed the Good work on this one — the test coverage for the new function looks solid too! 🙏 |
Thanks, I have some pending review tasks on these two PR. But due natural calamity, I didnot fixed it yesterday. |
|
@Ghraven, please review this PR, and let me know if it would be better to squash those commits, or you need any further changes. I added corresponding test cases for the new methods and updated all usages to align with the project’s new send_ingest workflow changes. |
yashksaini-coder
left a comment
There was a problem hiding this comment.
Ran locally: 65/65 pass, lint clean. Refactor logic is correct and the move of get_investigation_url into ingest_delivery.py makes sense — it shares the app.config dependency with send_ingest and has no business being in the formatters layer.
One functional regression though:
investigation_url fallback is lost
Old node.py always computed a URL even when ingest failed:
investigation_url = get_investigation_url(state.get("organization_slug"), investigation_id)
# investigation_id=None → returns "{base}/investigations" (the list page)The new helper only sets investigation_url when investigation_id is not None, so on first-ingest failure it returns (None, None). The call site then does:
build_action_blocks(investigation_url or "", investigation_id)Slack's Block Kit rejects an empty string on the button's url field — the "View Details in Tracer" button will break whenever ingest is down or unreachable. The old behavior (fallback to the investigations list URL) should be preserved. Simplest fix is to always call get_investigation_url in the helper regardless of whether investigation_id is set:
investigation_url = get_investigation_url(state.get("organization_slug"), investigation_id)and remove the investigation_url or "" guard at the call site.
Minor — test_node.py patches internals instead of the helper
test_masking_unmask.py patches create_investigation_and_attach_url wholesale, which is the right approach for an integration-level test. test_node.py still patches send_ingest and get_investigation_url at the utility module level — it works but locks the test to the helper's internal structure. Worth aligning to the same strategy.
The refactor itself is clean and the three new tests in test_ingest_delivery.py cover the right paths. Fix the URL fallback and this is good to merge.
|
Okay, will do.
…On Thu, Apr 30, 2026 at 11:21 AM Yash Kumar Saini ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Ran locally: 65/65 pass, lint clean. Refactor logic is correct and the
move of get_investigation_url into ingest_delivery.py makes sense — it
shares the app.config dependency with send_ingest and has no business
being in the formatters layer.
One functional regression though:
*investigation_url fallback is lost*
Old node.py always computed a URL even when ingest failed:
investigation_url = get_investigation_url(state.get("organization_slug"), investigation_id)# investigation_id=None → returns "{base}/investigations" (the list page)
The new helper only sets investigation_url when investigation_id is not
None, so on first-ingest failure it returns (None, None). The call site
then does:
build_action_blocks(investigation_url or "", investigation_id)
Slack's Block Kit rejects an empty string on the button's url field — the
"View Details in Tracer" button will break whenever ingest is down or
unreachable. The old behavior (fallback to the investigations list URL)
should be preserved. Simplest fix is to always call get_investigation_url
in the helper regardless of whether investigation_id is set:
investigation_url = get_investigation_url(state.get("organization_slug"), investigation_id)
and remove the investigation_url or "" guard at the call site.
------------------------------
*Minor — test_node.py patches internals instead of the helper*
test_masking_unmask.py patches create_investigation_and_attach_url
wholesale, which is the right approach for an integration-level test.
test_node.py still patches send_ingest and get_investigation_url at the
utility module level — it works but locks the test to the helper's internal
structure. Worth aligning to the same strategy.
------------------------------
The refactor itself is clean and the three new tests in
test_ingest_delivery.py cover the right paths. Fix the URL fallback and
this is good to merge.
—
Reply to this email directly, view it on GitHub
<#1086 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AU4OIYAT5JV6JQT3CKIKLI34YLSXXAVCNFSM6AAAAACYLF5DD2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHM2DEMBSG4YTMMBTHE>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Thanks for the updates @SB2318 — both points I raised look good now:
I also noticed On squashing — I'd lean toward keeping the commits separate for now since the history is readable and the maintainers may want to see the progression. But that's ultimately muddlebee's call. Looks solid to me! 🙏 |
With empty string removal, your test is falling. |
|
@yashksaini-coder Please check my comment on these two issues. |
|
@SB2318 pls fix CI |
okay |
Fixes #867
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
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.