-
Notifications
You must be signed in to change notification settings - Fork 98
fix: show unpkg-white-list version on sync log #934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughExposes the unpkg whitelist version via a new public getter and updates error messages and logs in PackageSyncerService and PackageVersionFileService to include that whitelist version. Adds a test asserting 404 for a wildcard ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (5)**/*.{js,ts,tsx,jsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
test/**/*.test.ts📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
app/core/service/**/*.ts📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🧠 Learnings (9)📚 Learning: 2025-11-29T15:42:37.586ZApplied to files:
📚 Learning: 2025-11-29T15:42:56.815ZApplied to files:
📚 Learning: 2025-11-29T15:42:37.586ZApplied to files:
📚 Learning: 2025-11-29T15:42:56.815ZApplied to files:
📚 Learning: 2025-11-29T15:42:37.586ZApplied to files:
📚 Learning: 2025-11-29T15:42:37.586ZApplied to files:
📚 Learning: 2025-11-29T15:42:37.586ZApplied to files:
📚 Learning: 2025-11-29T15:42:37.586ZApplied to files:
📚 Learning: 2025-11-29T15:42:37.586ZApplied to files:
🧬 Code graph analysis (1)app/core/service/PackageSyncerService.ts (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #934 +/- ##
==========================================
- Coverage 95.39% 95.27% -0.12%
==========================================
Files 197 197
Lines 22263 22263
Branches 2075 2456 +381
==========================================
- Hits 21237 21212 -25
- Misses 1026 1051 +25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
app/core/service/PackageSyncerService.ts (2)
886-907: Whitelist version now included in error messages and logs.The changes correctly expose and include the unpkg whitelist version in error messages and logs, which will improve debugging. The variable renaming from the method result to
allowedis clear and concise.However, lines 893 and 906 exceed the 120-character line width limit specified in the coding guidelines.
Consider breaking these long lines:
- task.error = `Synced version ${version} fail, large package version size: ${size}, allow size: ${this.config.cnpmcore.largePackageVersionSize}, see ${UNPKG_WHITE_LIST_URL}, white list version: ${whiteListVersion}`; + task.error = `Synced version ${version} fail, large package version size: ${size}, ` + + `allow size: ${this.config.cnpmcore.largePackageVersionSize}, ` + + `see ${UNPKG_WHITE_LIST_URL}, white list version: ${whiteListVersion}`;- `[${isoNow()}] 🚧 [${syncIndex}] Synced version ${version} size: ${size} too large, it is allowed to sync by unpkg white list, white list version: ${whiteListVersion}`, + `[${isoNow()}] 🚧 [${syncIndex}] Synced version ${version} size: ${size} too large, ` + + `it is allowed to sync by unpkg white list, white list version: ${whiteListVersion}`,
1391-1412: Whitelist version included in packument sync flow.The changes mirror the updates made in the main sync flow (lines 886-907) and correctly include the whitelist version in error messages and logs.
However, lines 1398 and 1411 exceed the 120-character line width limit.
Consider breaking these long lines for consistency with coding guidelines:
- task.error = `Synced version ${version} fail, large package version size: ${size}, allow size: ${this.config.cnpmcore.largePackageVersionSize}, see ${UNPKG_WHITE_LIST_URL}, white list version: ${whiteListVersion}`; + task.error = `Synced version ${version} fail, large package version size: ${size}, ` + + `allow size: ${this.config.cnpmcore.largePackageVersionSize}, ` + + `see ${UNPKG_WHITE_LIST_URL}, white list version: ${whiteListVersion}`;- `[${isoNow()}] 🚧 [${syncIndex}] Synced version ${version} size: ${size} too large, it is allowed to sync by unpkg white list, white list version: ${whiteListVersion}`, + `[${isoNow()}] 🚧 [${syncIndex}] Synced version ${version} size: ${size} too large, ` + + `it is allowed to sync by unpkg white list, white list version: ${whiteListVersion}`,app/core/service/PackageVersionFileService.ts (1)
176-202: Whitelist version now included in unpkg validation errors.The error messages now include the whitelist version, which will help users understand which version of the whitelist is being enforced. This aligns with the PR's objective of improving observability.
However, lines 187 and 199 exceed the 120-character line width limit specified in the coding guidelines.
Consider breaking these long error message strings:
- throw new ForbiddenError(`"${fullname}" is not allow to unpkg files, see ${UNPKG_WHITE_LIST_URL}, white list version: ${this.#unpkgWhiteListCurrentVersion}`); + throw new ForbiddenError( + `"${fullname}" is not allow to unpkg files, see ${UNPKG_WHITE_LIST_URL}, ` + + `white list version: ${this.#unpkgWhiteListCurrentVersion}`, + );- `"${fullname}@${pkgVersion}" not satisfies "${pkgConfig.version}" to unpkg files, see ${UNPKG_WHITE_LIST_URL}, white list version: ${this.#unpkgWhiteListCurrentVersion}`, + `"${fullname}@${pkgVersion}" not satisfies "${pkgConfig.version}" to unpkg files, ` + + `see ${UNPKG_WHITE_LIST_URL}, white list version: ${this.#unpkgWhiteListCurrentVersion}`,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
app/core/service/PackageSyncerService.ts(4 hunks)app/core/service/PackageVersionFileService.ts(2 hunks)test/port/controller/package/ShowPackageVersionController.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{js,ts,tsx,jsx}: Use single quotes in JavaScript/TypeScript code (from Prettier configuration)
Use 2-space indentation (from Prettier configuration)
Maintain 120 character line width maximum (from Prettier configuration)
Use trailing commas in ES5 syntax (from Prettier configuration)
Avoid parentheses in arrow functions when possible (from Prettier configuration)
Maximum of 6 function parameters (from Oxlint configuration)
Warn on console usage (from Oxlint configuration)
Disallow anonymous default exports (from Oxlint configuration)
Use ES modules (import/export) syntax throughout
Files:
app/core/service/PackageVersionFileService.tstest/port/controller/package/ShowPackageVersionController.test.tsapp/core/service/PackageSyncerService.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use strict TypeScript with comprehensive type definitions - avoidanytypes, use proper typing orunknown
Export types and interfaces for reusability in TypeScript
Files:
app/core/service/PackageVersionFileService.tstest/port/controller/package/ShowPackageVersionController.test.tsapp/core/service/PackageSyncerService.ts
app/core/service/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
app/core/service/**/*.ts: Services must implement core business logic without HTTP concerns or direct database access
Services must use@SingletonProto()for service lifecycle management
Services must orchestrate multiple repositories and entities, managing transactions and events
Files:
app/core/service/PackageVersionFileService.tsapp/core/service/PackageSyncerService.ts
**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.ts: Use strict TypeScript with proper typing - avoidanytypes, use proper typing orunknowninstead
Use ES modules withimport/exportsyntax throughout the codebase
Use single quotes (') for strings
Use 2-space indentation
Enforce 120 character line width
Use ES5 trailing commas
Limit functions to a maximum of 6 parameters
Do not use console statements - use logger instead
Files:
app/core/service/PackageVersionFileService.tstest/port/controller/package/ShowPackageVersionController.test.tsapp/core/service/PackageSyncerService.ts
test/**/*.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
test/**/*.test.ts: Test files must use.test.tssuffix
Tests must use@eggjs/mockfor mocking and testing
Tests must useassertfromnode:assert/strictfor assertions
Test files should be organized intest/directory mirroring source structure
Mock external dependencies usingmock()from@eggjs/mockin tests
Use realistic test data created throughTestUtilhelper methods
Clean up after tests - database is reset between test files
Test both success and failure cases - error paths are equally important
Test files should follow naming pattern: describe('[HTTP_METHOD /api/path] functionName()', ...)
test/**/*.test.ts: Test files must use.test.tssuffix
Use@eggjs/mockfor mocking in test files
Useassertfromnode:assert/strictin test files
Test files must mirror source structure intest/directory and test both success and error cases
Files:
test/port/controller/package/ShowPackageVersionController.test.ts
🧠 Learnings (3)
📚 Learning: 2025-11-29T15:42:37.586Z
Learnt from: CR
Repo: cnpm/cnpmcore PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T15:42:37.586Z
Learning: Applies to test/**/*.test.ts : Test both success and failure cases - error paths are equally important
Applied to files:
test/port/controller/package/ShowPackageVersionController.test.ts
📚 Learning: 2025-11-29T15:42:56.815Z
Learnt from: CR
Repo: cnpm/cnpmcore PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-29T15:42:56.815Z
Learning: Applies to test/**/*.test.ts : Test files must mirror source structure in `test/` directory and test both success and error cases
Applied to files:
test/port/controller/package/ShowPackageVersionController.test.ts
📚 Learning: 2025-11-29T15:42:37.586Z
Learnt from: CR
Repo: cnpm/cnpmcore PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T15:42:37.586Z
Learning: Applies to test/**/*.test.ts : Test files should follow naming pattern: describe('[HTTP_METHOD /api/path] functionName()', ...)
Applied to files:
test/port/controller/package/ShowPackageVersionController.test.ts
🧬 Code graph analysis (3)
app/core/service/PackageVersionFileService.ts (1)
app/core/entity/Package.ts (1)
fullname(63-65)
test/port/controller/package/ShowPackageVersionController.test.ts (3)
app/core/service/PackageVersionFileService.ts (1)
pkg(345-388)app/port/controller/package/RemovePackageVersionController.ts (1)
pkg(80-95)test/TestUtil.ts (2)
TestUtil(66-402)app(167-172)
app/core/service/PackageSyncerService.ts (2)
app/core/service/PackageVersionFileService.ts (1)
UNPKG_WHITE_LIST_URL(24-24)app/common/LogUtil.ts (1)
isoNow(1-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: Agent
- GitHub Check: test on mysql (node@20, shard@1/3, enableJSONBuilder@true)
- GitHub Check: test on mysql (node@20, shard@2/3, enableJSONBuilder@true)
- GitHub Check: test on mysql (node@24, shard@2/3, enableJSONBuilder@false)
- GitHub Check: test on mysql (node@24, shard@0/3, enableJSONBuilder@true)
- GitHub Check: test on mysql (node@24, shard@1/3, enableJSONBuilder@true)
- GitHub Check: test on mysql (node@20, shard@2/3, enableJSONBuilder@false)
- GitHub Check: test on mysql (node@22, shard@2/3, enableJSONBuilder@false)
- GitHub Check: test on mysql (node@20, shard@1/3, enableJSONBuilder@false)
- GitHub Check: test on mysql (node@24, shard@2/3, enableJSONBuilder@true)
- GitHub Check: build-and-push-image
- GitHub Check: test on mysql (node@20, shard@0/3, enableJSONBuilder@false)
- GitHub Check: test on postgresql (node@22, shard@0/3)
- GitHub Check: test on postgresql (node@22, shard@1/3)
- GitHub Check: test on postgresql (node@20, shard@2/3)
- GitHub Check: test on postgresql (node@24, shard@2/3)
- GitHub Check: test on postgresql (node@24, shard@1/3)
- GitHub Check: test on postgresql (node@24, shard@0/3)
- GitHub Check: test on postgresql (node@20, shard@1/3)
- GitHub Check: test on postgresql (node@20, shard@0/3)
🔇 Additional comments (2)
test/port/controller/package/ShowPackageVersionController.test.ts (1)
215-233: LGTM! Well-structured test for wildcard version spec.The test correctly validates 404 behavior when requesting a wildcard version spec (
*) that doesn't match any stable versions (only a pre-release version exists). This aligns with the PR's objective of improving error messaging.app/core/service/PackageVersionFileService.ts (1)
68-70: LGTM! Clean public getter for whitelist version.The getter provides a clean interface for other services to access the unpkg whitelist version, enabling the improved error messaging throughout the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances error messages and logs related to the unpkg white list feature by adding the white list version information to help administrators debug package sync issues more effectively.
Key changes:
- Adds a public getter
unpkgWhiteListVersionto expose the current white list version - Updates error messages and log entries to include the white list version when large packages are rejected or allowed
- Refactors variable naming for clarity (
isAllowLargePackageVersion→allowed) - Translates Chinese comments to English for better maintainability
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/core/service/PackageVersionFileService.ts | Adds getter for white list version; updates error messages to include version info; translates comments to English |
| app/core/service/PackageSyncerService.ts | Updates sync logs and error messages to include white list version; refactors variable naming for clarity |
| test/port/controller/package/ShowPackageVersionController.test.ts | Adds test for * version spec returning 404 when only pre-release versions exist (appears unrelated to main PR purpose) |
| it('should 404 when `*` version spec not found', async () => { | ||
| const pkg = await TestUtil.getFullPackage({ | ||
| name: '@cnpm/foo-tag-latest-star', | ||
| version: '0.1.0-alpha.0', | ||
| versionObject: { | ||
| description: 'foo latest description', | ||
| }, | ||
| }); | ||
| let res = await app | ||
| .httpRequest() | ||
| .put(`/${pkg.name}`) | ||
| .set('authorization', publisher.authorization) | ||
| .set('user-agent', publisher.ua) | ||
| .send(pkg); | ||
| assert.equal(res.status, 201); | ||
| res = await app.httpRequest().get(`/${pkg.name}/*`); | ||
| assert.equal(res.status, 404); | ||
| assert.equal(res.body.error, `[NOT_FOUND] ${pkg.name}@* not found`); | ||
| }); |
Copilot
AI
Dec 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case appears unrelated to the PR's stated purpose of "show unpkg-white-list version on sync log". The test validates that querying a package with only pre-release versions using the * version spec returns 404, which is about semver range matching behavior, not white list version logging. Consider moving this test to a separate PR focused on version resolution behavior, or if it was intended to be part of a different commit, it may have been added to this PR by mistake.
[skip ci] ## <small>4.17.1 (2025-12-16)</small> * fix: show unpkg-white-list version on sync log (#934) ([0f4aeff](0f4aeff)), closes [#934](#934) [hi#level](https://github.com/hi/issues/level) * chore(deps): update dependency oxlint-tsgolint to ^0.9.0 (#930) ([ba37c25](ba37c25)), closes [#930](#930)
|
🎉 This PR is included in version 4.17.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary by CodeRabbit
Bug Fixes
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.