Keep ordered SQL resolver results aligned after encoding failures - #7001
Conversation
🦋 Changeset detectedLatest commit: 4c7d053 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Important
This PR currently contains only the failing regression test; the implementation fix described in the PR body is still missing. The test is correct and reproduces the bug accurately, but it cannot be approved until the corresponding fix in SqlResolver.ts lands on the same branch.
Reviewed changes
- Added a regression test in
packages/effect/test/unstable/sql/SqlResolver.test.tsdemonstrating thatSqlResolver.orderedmisaligns results when one batched request fails schema encoding.
@v0 or keep the SHA fresh with Dependabot | Fix it ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Implemented the
SqlResolver.orderedalignment fix inpackages/effect/src/unstable/sql/SqlResolver.ts:partitionRequestsnow returns the surviving encoded entries alongside encoded inputs, andorderedcompletes only those entries by matching positional index. - Updated
groupedandvoid_callers to destructure the new tuple return frompartitionRequestswithout behavior changes. - Added the patch changeset
.changeset/calm-results-align.md. - Verified the regression test passes, and
pnpm lint/pnpm checkare clean.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
When one batched request fails schema encoding, a later valid request can be completed with the wrong positional result or undefined.
Important
This PR includes the focused regression test, implementation fix, and patch changeset.
Ordered results misalign after input encoding failure
Module:
SqlResolverAudit ID:
unstable-services-sql-resolver-ordered-alignmentSeverity / confidence: high / high
What happens
When one batched request fails schema encoding, a later valid request can be completed with the wrong positional result or undefined.
Why it happens
partitionRequests removes failed inputs without returning the surviving entries; ordered then indexes shortened decoded results using original entry indexes.
Expected behavior
Each successfully encoded request must receive its corresponding result, while a request that fails encoding must fail independently.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/effect/src/unstable/sql/SqlResolver.ts:123-136packages/effect/src/unstable/sql/SqlResolver.ts:323-345View problematic code at
packages/effect/src/unstable/sql/SqlResolver.ts:123-136View exact lines on GitHub
View problematic code at
packages/effect/src/unstable/sql/SqlResolver.ts:323-345View exact lines on GitHub
Reproduction
pnpm test --run packages/effect/test/unstable/sql/SqlResolver.test.tsObserved failure: FAIL: the valid request succeeded with undefined instead of value-2.
Validation
pnpm test --run packages/effect/test/unstable/sql/SqlResolver.test.tspnpm test --run --project effectpnpm lintpnpm checkAudit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715funstable-services-sql-resolver-ordered-alignmentCloses EFF-438