Fix: Prevent duplicate buffers in join operations #179
Fix: Prevent duplicate buffers in join operations #179kishore08-07 wants to merge 5 commits intoopen-rmf:mainfrom
Conversation
Signed-off-by: GitHub <noreply@github.com>
There was a problem hiding this comment.
Pull request overview
Adds an upfront validation step to join construction so specifying the same buffer multiple times is detected early (instead of failing later at runtime), addressing issue #61.
Changes:
- Introduces
DuplicateBufferand asafe_joinpath that returns aResultwhen duplicates are detected. - Updates existing
join/join_vecAPIs to route throughsafe_joinand keep the existing panic-on-error behavior. - Adds regression tests covering both the
safe_joinerror case and thejoinpanic case.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/buffer/buffering.rs |
Defines DuplicateBuffer, adds duplicate detection, and implements Joining::safe_join used by join construction. |
src/buffer/bufferable.rs |
Exposes safe_join/safe_join_vec on Joinable and IterBufferable, and routes existing join helpers through them. |
src/builder.rs |
Adds Builder::safe_join convenience wrapper returning Result<Chain, DuplicateBuffer>. |
src/operation/join.rs |
Adds tests ensuring duplicates are rejected via safe_join and cause a panic via join. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ests Signed-off-by: GitHub <noreply@github.com>
mxgrey
left a comment
There was a problem hiding this comment.
Thanks for the contribution! This is a good match of what I recommended in the original issue ticket. I left a few comments about adding missing inline documentation.
One additional point we should address is fn try_join. This method supports dynamic joining, needed for JSON diagram workflows. It already returns an error message if the input layout is incompatible with the type that is being joined into, but currently there is no check to prevent multiple buffers from being used.
We should change the error type of try_join to an enum with variants of IncompatibleLayout and DuplicateBuffer, and we should look through the BufferMap for buffers with duplicate IDs. If there are any duplicate IDs then try_join should return the DuplicateBuffer variant.
…t for try_join duplicates Signed-off-by: kishore08-07 <kishorebsm8@gmail.com>
|
@mxgrey Thank you for the detailed feedback!
All review points are now addressed, kindly review when you have time and let me know if any further changes are required. |
|
@kishore08-07 note that the CI tests are failing. When validating your changes be sure to run each of the following: It's important to run |
Signed-off-by: kishore08-07 <kishorebsm8@gmail.com>
@mxgrey I've run the above test commands as suggested. CI errors are resolved and all tests are now passing locally. Changes have been committed. |
Bug fix
Fixed bug
Fix applied
Added a
DuplicateBuffererror type and asafe_joinmethod to check for duplicate buffers at join construction time.The
safe_joinmethod returns a clear error if duplicates are found, preventing the workflow from being built incorrectly.The existing
joinmethod now callssafe_joinand panics with a clear message if duplicates are present, preserving the previous panic-on-error API.Added corresponding methods to
Joinable,IterBufferable, andBuilderfor ergonomic usage.Added tests to ensure duplicate buffers are caught at construction time, both for the error case
safe_joinand the panic casejoin.This change ensures that duplicate buffer errors are detected early, providing a better user experience and preventing confusing runtime failures.
GenAI Use
We follow OSRA's policy on GenAI tools
Generated-by:
GPT-4.1