fix(crosslink): correct pruning logic to ensure all replace statement…#1597
fix(crosslink): correct pruning logic to ensure all replace statement…#1597Abhay349 wants to merge 2 commits intoopen-telemetry:mainfrom
Conversation
…s are removed Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1597 +/- ##
==========================================
+ Coverage 64.08% 64.16% +0.08%
==========================================
Files 66 66
Lines 3408 3427 +19
==========================================
+ Hits 2184 2199 +15
- Misses 988 990 +2
- Partials 236 238 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @dmathieu @mx-psi I attempted to add a specific unit test, however I encountered flaky behavior related to Let me know if there are issues, happy to iterate on feedback. |
|
I am not supportive of adding this without a unit test |
|
@mx-psi Totally understand your concern. I’ll revisit this and make another attempt at adding a proper unit test. If I run into issues while stabilizing it, I’ll reach out for guidance. |
0fe9429 to
23aaa19
Compare
|
Hi @mx-psi @dmathieu, |
|
Let me know if this approach looks good, happy to iterate on further feedback. |
|
The test you added does not seem to fail if I revert your changes on |
Description:
In continuation with PR #1593, this PR fixes a bug in the prune command where some replace statements were not being removed correctly.
Changes:
Pointer usage for in-place modification: Changed
modContentsto use a pointer. Previously, it was creating a value copy of the module struct, soDropReplacecalls were modifying a local copy that was discarded, leaving the original module unchanged.Safe iteration: Implemented a two-pass approach for pruning. We now collect all replace statements to be pruned into a toPrune slice first, and then iterate over that slice to remove them. This prevents index-shifting bugs that occur when modifying a slice (removing elements) while iterating over it, which previously caused some statements to be skipped.