Repository navigation
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Reviewer's GuideAPIMigrate the
ConfigurationUpgrade the Zod dependency to a version that supports the migrated function schemas.
TestsAdd regression coverage for accepted callback functions and rejected non-function callback options.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/index.ts" line_range="78" />
<code_context>
- get: z.function()
- .args(z.any())
- .returns(z.string()),
+ get: z.function({ input: [ z.any() ], output: z.string() }),
/**
* set the external key
</code_context>
<issue_to_address>
**Session package fails to load**
When the package is imported, zod 4's `z.function(...)` creates a function factory, not a schema that can be embedded in `z.object`; `SessionOptions.parse({})` therefore encounters non-schema fields during module initialization and throws, so consumers cannot import the package.
Use Zod 4-compatible schemas for validating callback values in `SessionOptions`, rather than embedding function factories in the object shape.
Also at `src/index.ts:83`, `src/index.ts:94`, `src/index.ts:99`, `src/index.ts:103`, `src/index.ts:111`, `src/index.ts:114`, `src/index.ts:121`, `src/index.ts:133`, `src/index.ts:138`.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: src/index.ts:78
|
CI follow-up: I investigated the failing Actions jobs after opening this PR. The test suite itself reports 122 passing on the checked Node.js versions. The jobs then fail in the post-test package validation step (npm run prepublishOnly -> tshy && tshy-after && attw --pack), with: To check whether this patch introduced the failure, I created a separate pristine worktree at upstream master commit 968ae94, ran npm install and npm run prepublishOnly there (without any Zod 4 changes), and reproduced the same attw error and exit code 3. The red CI status reflects a reproducible pre-existing package-validation failure, not failed session tests caused by this PR. I am keeping unrelated tooling changes out of this focused Koa 2 / Zod 4 compatibility patch; maintainer guidance would be appreciated. |
Summary
Keep the existing Koa 2 middleware API while migrating the Zod 3-only function schemas to Zod 4.
Motivation
Downstream Strapi 5 / Node 24 apps attempting to resolve their Zod dependency tree to patched Zod 4 fail when importing koa-session@7.0.2: the legacy function().args method is no longer available. Existing upstream PR #235 addresses Koa 3 and Zod 4 together. This patch is deliberately narrower for Koa 2 consumers.
Verification
Please run the supported upstream CI and review TypeScript function inference before release. This patch does not claim to resolve all downstream security vulnerabilities.
Related: #235 and strapi/strapi#28246
Summary by Sourcery
Enable Zod 4 compatibility for the existing Koa 2 session API without introducing public middleware changes.
Bug Fixes:
Enhancements:
Build:
Tests:
Summary by CodeRabbit