Repository navigation
0.18 PR2: validate strategies, remove fail/stopOnError aliases - #31
Merged
Merged
Conversation
Unknown strategies were silently treated as collect, and the deprecated fail/stopOnError aliases outlived their 0.18 removal. Both now raise a TypeError at construction, naming the API and the accepted values. 'rethrow' stays an alias of 'throw'; mapSeries/mapSeriesSync keep their rethrow lock and report it in the error. Plan: 0.18 PR 2 (fix/strategy-contract).
ildella
marked this pull request as ready for review
November 24, 2026 14:36
# Conflicts: # docs/migration.md
ildella
commented
Nov 24, 2026
ildella
left a comment
Owner
Author
There was a problem hiding this comment.
APPROVED
REVIEW: Both review passes found no valid medium-or-higher issues. A new import-free src/strategy-name.js normalizes strategy identifiers in one place; fail/stopOnError are no longer exported or accepted, 'rethrow' (string and {name}) behaves as 'throw', and unknown strategies throw a TypeError before the source is pulled across series/filter/folds/enrich/join/findSync and the sync twins. README, guide, reference and migration docs are consistent with the new contract.
FINDINGS: No valid medium-or-higher findings. Low/info follow-ups:
- INFO (reviewer proposed MEDIUM, downgraded) —
createRunStatecarries bothlabelandstrategyLabel. These are not duplicated state:labelis the optional sync-telemetry name used byassertSyncCallback(state.label, …)and is undefined on async runs, whilestrategyLabelis the API name for validation errors and is always set. Concretely, asyncseries()haslabel === undefined,strategyLabel === 'series'— they differ on every async call. Usinglabelalone, as the plan sketch suggests, would make telemetry dispatch treat async runs as sync and reject async callbacks; the separation is intentional and the JSDoc documents it. - LOW — validation errors on async
filter/enrichname the underlying engine:filter(items, pred, {strategy: 'bogus'})reportsseries() unknown strategy ..., andenrichreportsscan/reduce(). Trigger: any invalid strategy on those wrappers; behavior is correct and plan-conformant, only the wrapper name is missing from the message. - LOW —
mapSeries/mapSeriesSyncrejected-alias hint points to values they don't accept:mapSeries(..., {strategy: 'fail'})saysuse failFast, butfailFastis itself rejected by the always-rethrow API. Trigger: a user following the shared message; plan-prescribed wording. - LOW —
export const assertStrategy = strategyNameOfis a second name for one function (onlyshared.jsimports the alias), andknip.jsonadds aduplicatessuppression for the new module. Trigger: future callers importing either name diverge; plan §2a prescribes the alias, so not blocking. - LOW — several tests assert exact error strings, e.g.
new TypeError('series() strategy "fail" was removed in 0.18; use failFast'). Trigger: a benign wording change forces multi-file test edits. - INFO — the new file repeats the canonical strategy set as objects, strings and "all others" lists; adding a strategy could update only one. Coverage of
'rethrow'on join/folds/findSync and invalid strategies on folds/findSync/enrich is not pinned. - INFO — the branch was merged with master after reviews started; the current diff's migration header now correctly reads "one soft deprecation, two additive changes and two breaking ones", resolving the earlier cross-PR conflict with PR 29.
CI: green — the test check (Code Check workflow) succeeded.
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.
What
PR 2 of the 0.18 stabilization plan (
fix/strategy-contract).src/strategy-name.js:strategyNameOf/assertStrategynormalize a strategy to its canonical name and throw a
TypeErrorotherwise.createRunState(soseries/filter/scan/reduce/enrich/findSyncvalidate when the operation is built, before the source is pulled),assertRethrowStrategy(mapSeries/mapSeriesSync) andjoin.failandstopOnErroraliases fromsrc/strategy.jsand the public re-exports.'rethrow'(string or{name: 'rethrow'}) still works as an alias of'throw';mapSeries/mapSeriesSyncstill only acceptrethrow/throwand keep their "always rethrows" error for other strategies.series(),seriesSync(),scan/reduce(),join(),findSync(),mapSeries(),mapSeriesSync().Why
An unknown strategy used to fall through every branch in
failOnItem/failOnSourceand behave likecollect— a silent policy change. The aliases were scheduled for removal in 0.18. Both now fail fast with an actionable message.Tests
tests/strategy-validation.test.js: valid strategy objects on series/filter/folds/enrich/join/findSync, valid strings,rethrowalias behavior, removed aliases (TypeError"use failFast"), unknown values ('failfast',null,42,{}), validation before the source is pulled, themapSeriesrethrow lock, and nofail/stopOnErrorin the public namespace.tests/error-strategies.test.jsandtests/join-error-strategies.test.js.nullstrategy expectations in themapSeries/mapSeriesSynctests: unknown names now get the shared "unknown strategy" message.Docs
README error-model table, guide
failFast/rethrowsections, reference TOC/failFast/rethrow/join/matrix, migration 0.18 (Removed: fail / stopOnError, invalid strategies throw), skill already had no aliases.Verification
yarn lint— cleanyarn vitest run— 72 files / 967 tests passedyarn check— lint + dup (0 clones) + knip cleanknip.jsonignoresduplicatesforsrc/strategy-name.js, matching the existingsrc/strategy.jsentry: the plan asks forassertStrategyto be exported as an alias ofstrategyNameOf, which knip otherwise reports as a duplicate export.Plan reference:
/home/della/.opencode/plan/pipelean-0.18.md, PR 2 (lines 168-255), non-goals/risks sections 4-5.