Fix issue #9: Distinguish pipe tokens from regular objects with .run() method - #12
Merged
Conversation
…) method Co-authored-by: irony <395843+irony@users.noreply.github.com>
irony
marked this pull request as ready for review
October 9, 2025 20:15
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses issue #9 by implementing a solution to distinguish between pipe tokens and regular objects that have a .run() method. The problem was that the library automatically executed .run() on any object containing this method, preventing users from returning legitimate objects like tasks or commands.
- Added a
PIPE_TOKENSymbol to mark actual pipe tokens for proper identification - Modified the auto-execution logic to only call
.run()on objects marked with the symbol - Created comprehensive unit tests to verify the fix and prevent regression
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| index.js | Added PIPE_TOKEN Symbol and updated auto-execution checks to distinguish pipe tokens from regular objects |
| test.js | Added 4 unit tests covering various scenarios of objects with .run() methods and pipe token behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Copilot
AI
changed the title
[WIP] Add unit tests for issue #9 and propose solution
Fix issue #9: Distinguish pipe tokens from regular objects with .run() method
Oct 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The aspipes library was incorrectly treating any object with a
.run()method as a pipe token, automatically calling that method during pipeline execution. This made it impossible for users to return objects that legitimately have arunmethod, such as task objects, command objects, or job objects.For example, this would fail:
Root Cause
The implementation checked
if (result && typeof result.run === 'function')to detect composed pipes that should be unwrapped. However, this check was too broad and couldn't distinguish between:pipe()) that should be auto-executed.run()methodSolution
Added a unique Symbol (
PIPE_TOKEN) to mark objects as actual pipe tokens. The library now checks for both the presence of.run()and thePIPE_TOKENmarker before unwrapping:This allows the library to correctly handle both scenarios:
.run()method are returned as-is ✓Changes
index.js: Added Symbol marker and updated auto-execution checks (10 lines changed)test.js: 4 new unit tests covering various scenarios (107 lines added)Testing
All 48 tests pass (44 existing + 4 new), confirming:
.run()are preservedThe fix is minimal, surgical, and maintains the library's existing behavior while enabling the new use case.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/irony/aspipes/issues/9curl -s REDACTED(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.