Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Dec 16, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Error messages for large package version restrictions now include the unpkg whitelist version for clearer troubleshooting.
  • New Features

    • Exposed the current unpkg whitelist version via a public getter for visibility in messages.
  • Tests

    • Added a test for wildcard version handling and relaxed several forbidden-error assertions to accept minor message variations.

✏️ Tip: You can customize this high-level summary in your review settings.

@fengmk2 fengmk2 requested review from Copilot and elrrrrrrr December 16, 2025 10:04
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit 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.

Walkthrough

Exposes 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 (*) version spec not found.

Changes

Cohort / File(s) Summary
Whitelist getter & message updates
app/core/service/PackageVersionFileService.ts, app/core/service/PackageSyncerService.ts
Added unpkgWhiteListVersion getter; replaced isLargePackageVersionAllowed with allowed; updated error messages and log lines to include the whitelist version and added a dedicated fail log label for large-package-version failures.
Tests — wildcard and message matching
test/port/controller/package/ShowPackageVersionController.test.ts, test/port/controller/PackageVersionFileController/listFiles.test.ts, test/port/controller/PackageVersionFileController/raw.test.ts
Added a 404 test for wildcard (*) version spec; broadened several tests to use regex matches for forbidden error messages instead of exact string equality.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Focus areas for review:
    • PackageVersionFileService.ts — correctness and exposure of the new getter and error message text.
    • PackageSyncerService.ts — consistent use of allowed and inclusion of whiteListVersion in all affected log/error paths.
    • Tests — ensure regex assertions still validate intended error semantics without being over-broad.

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • elrrrrrrr

Poem

🐇 I hopped in code to show a name,
A whitelist version joined the game,
Logs now tell which version's right,
Tests watch stars and guard the night,
Hooray — the rabbit checked the frame! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: exposing and displaying the unpkg-white-list version in sync logs across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch show-unpkg-version

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2414c49 and 067947a.

📒 Files selected for processing (4)
  • app/core/service/PackageSyncerService.ts (4 hunks)
  • app/core/service/PackageVersionFileService.ts (2 hunks)
  • test/port/controller/PackageVersionFileController/listFiles.test.ts (4 hunks)
  • test/port/controller/PackageVersionFileController/raw.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/core/service/PackageVersionFileService.ts
🧰 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:

  • test/port/controller/PackageVersionFileController/raw.test.ts
  • test/port/controller/PackageVersionFileController/listFiles.test.ts
  • app/core/service/PackageSyncerService.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Use strict TypeScript with comprehensive type definitions - avoid any types, use proper typing or unknown
Export types and interfaces for reusability in TypeScript

Files:

  • test/port/controller/PackageVersionFileController/raw.test.ts
  • test/port/controller/PackageVersionFileController/listFiles.test.ts
  • app/core/service/PackageSyncerService.ts
test/**/*.test.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

test/**/*.test.ts: Test files must use .test.ts suffix
Tests must use @eggjs/mock for mocking and testing
Tests must use assert from node:assert/strict for assertions
Test files should be organized in test/ directory mirroring source structure
Mock external dependencies using mock() from @eggjs/mock in tests
Use realistic test data created through TestUtil helper 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.ts suffix
Use @eggjs/mock for mocking in test files
Use assert from node:assert/strict in test files
Test files must mirror source structure in test/ directory and test both success and error cases

Files:

  • test/port/controller/PackageVersionFileController/raw.test.ts
  • test/port/controller/PackageVersionFileController/listFiles.test.ts
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.ts: Use strict TypeScript with proper typing - avoid any types, use proper typing or unknown instead
Use ES modules with import/export syntax 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:

  • test/port/controller/PackageVersionFileController/raw.test.ts
  • test/port/controller/PackageVersionFileController/listFiles.test.ts
  • app/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/PackageSyncerService.ts
🧠 Learnings (9)
📚 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/PackageVersionFileController/raw.test.ts
  • test/port/controller/PackageVersionFileController/listFiles.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 : Use `assert` from `node:assert/strict` in test files

Applied to files:

  • test/port/controller/PackageVersionFileController/raw.test.ts
  • test/port/controller/PackageVersionFileController/listFiles.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 : Tests must use `assert` from `node:assert/strict` for assertions

Applied to files:

  • test/port/controller/PackageVersionFileController/raw.test.ts
  • test/port/controller/PackageVersionFileController/listFiles.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/PackageVersionFileController/raw.test.ts
  • test/port/controller/PackageVersionFileController/listFiles.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 must use `.test.ts` suffix

Applied to files:

  • test/port/controller/PackageVersionFileController/raw.test.ts
  • test/port/controller/PackageVersionFileController/listFiles.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/PackageVersionFileController/raw.test.ts
  • test/port/controller/PackageVersionFileController/listFiles.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 be organized in `test/` directory mirroring source structure

Applied to files:

  • test/port/controller/PackageVersionFileController/raw.test.ts
  • test/port/controller/PackageVersionFileController/listFiles.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 : Use realistic test data created through `TestUtil` helper methods

Applied to files:

  • test/port/controller/PackageVersionFileController/raw.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 app/port/controller/**/*.ts : Controllers must use `userRoleManager.requiredPackageMaintainer()` to prevent horizontal privilege escalation

Applied to files:

  • test/port/controller/PackageVersionFileController/raw.test.ts
🧬 Code graph analysis (1)
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: test on mysql (node@22, shard@0/3, enableJSONBuilder@true)
  • GitHub Check: test on mysql (node@20, shard@1/3, enableJSONBuilder@false)
  • GitHub Check: test on mysql (node@24, shard@1/3, enableJSONBuilder@false)
  • GitHub Check: test on mysql (node@20, shard@1/3, enableJSONBuilder@true)
  • GitHub Check: test on mysql (node@24, shard@0/3, enableJSONBuilder@false)
  • GitHub Check: test on mysql (node@24, shard@1/3, enableJSONBuilder@true)
  • GitHub Check: test on mysql (node@22, shard@1/3, enableJSONBuilder@false)
  • GitHub Check: test on mysql (node@24, shard@2/3, enableJSONBuilder@false)
  • GitHub Check: test on mysql (node@22, shard@2/3, enableJSONBuilder@false)
  • GitHub Check: test on mysql (node@22, shard@1/3, enableJSONBuilder@true)
  • GitHub Check: test on postgresql (node@20, shard@0/3)
  • GitHub Check: test on postgresql (node@24, shard@1/3)
  • GitHub Check: test on postgresql (node@22, shard@1/3)
  • GitHub Check: test on postgresql (node@22, shard@0/3)
  • GitHub Check: test on postgresql (node@24, shard@0/3)
  • GitHub Check: test on postgresql (node@24, shard@2/3)
  • GitHub Check: test on postgresql (node@20, shard@2/3)
  • GitHub Check: test on postgresql (node@20, shard@1/3)
  • GitHub Check: test on postgresql (node@22, shard@2/3)
  • GitHub Check: build-and-push-image
🔇 Additional comments (4)
test/port/controller/PackageVersionFileController/raw.test.ts (1)

138-141: LGTM! Appropriate regex-based assertion for dynamic error message.

The change from exact string matching to regex-based assertion correctly accommodates the dynamic white list version now included in the error message. The regex pattern is properly escaped and flexible.

app/core/service/PackageSyncerService.ts (2)

886-889: LGTM! Clear variable naming and informative error message.

The refactoring improves code readability by using descriptive variable names (allowed, whiteListVersion). Including the white list version in the error message helps users understand which version of the white list was evaluated, fulfilling the PR objective.


902-902: LGTM! Consistent logging for white list version.

The log message appropriately includes the white list version when large packages are allowed to sync, providing transparency and audit trail. The format is consistent with the error message at line 889.

Note: Lines 1387-1390 and 1403 apply the same pattern in the packument sync path, maintaining consistency across both sync implementations.

test/port/controller/PackageVersionFileController/listFiles.test.ts (1)

785-788: LGTM! Consistent regex-based assertions across all white list tests.

All four test updates appropriately replace exact string matching with regex-based assertions to accommodate the dynamic white list version now included in error messages. The regex patterns:

  • Properly escape special characters (URLs, quotes, parentheses)
  • Maintain specific error message validation
  • End with white list version: to flexibly match the appended version
  • Are consistent with the changes in raw.test.ts

This approach prevents test brittleness while preserving meaningful error message validation.

Based on learnings, test files should test both success and error cases, and these changes maintain that coverage while adapting to the new error message format.

Also applies to: 834-837, 991-994, 1112-1115


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.27%. Comparing base (ba37c25) to head (067947a).
⚠️ Report is 2 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 allowed is 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

📥 Commits

Reviewing files that changed from the base of the PR and between ba37c25 and 2414c49.

📒 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.ts
  • test/port/controller/package/ShowPackageVersionController.test.ts
  • app/core/service/PackageSyncerService.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Use strict TypeScript with comprehensive type definitions - avoid any types, use proper typing or unknown
Export types and interfaces for reusability in TypeScript

Files:

  • app/core/service/PackageVersionFileService.ts
  • test/port/controller/package/ShowPackageVersionController.test.ts
  • app/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.ts
  • app/core/service/PackageSyncerService.ts
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.ts: Use strict TypeScript with proper typing - avoid any types, use proper typing or unknown instead
Use ES modules with import/export syntax 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.ts
  • test/port/controller/package/ShowPackageVersionController.test.ts
  • app/core/service/PackageSyncerService.ts
test/**/*.test.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

test/**/*.test.ts: Test files must use .test.ts suffix
Tests must use @eggjs/mock for mocking and testing
Tests must use assert from node:assert/strict for assertions
Test files should be organized in test/ directory mirroring source structure
Mock external dependencies using mock() from @eggjs/mock in tests
Use realistic test data created through TestUtil helper 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.ts suffix
Use @eggjs/mock for mocking in test files
Use assert from node:assert/strict in test files
Test files must mirror source structure in test/ 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.

Copy link
Contributor

Copilot AI left a 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 unpkgWhiteListVersion to 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 (isAllowLargePackageVersionallowed)
  • 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)

Comment on lines +215 to +233
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`);
});
Copy link

Copilot AI Dec 16, 2025

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.

Copilot uses AI. Check for mistakes.
@fengmk2 fengmk2 merged commit 0f4aeff into master Dec 16, 2025
37 of 38 checks passed
@fengmk2 fengmk2 deleted the show-unpkg-version branch December 16, 2025 11:45
fengmk2 pushed a commit that referenced this pull request Dec 16, 2025
[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)
@github-actions
Copy link

🎉 This PR is included in version 4.17.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants