8000 fix: latest version maybe not exists by fengmk2 · Pull Request #814 · cnpm/cnpmcore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

fix: latest version maybe not exists #814

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 a 8000 nd privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025

Conversation

fengmk2
Copy link
Member
@fengmk2 fengmk2 commented Jun 26, 2025
2025-06-26 15:12:05,133 ERROR 423473 [-/127.0.0.1/ea0a01e1-5a66-4191-92c7-f06aa5bb86ea/19.41ms GET /] nodejs.TypeError: [EventBus] process event PACKAGE_MAINTAINER_REMOVED for handler packageVersionAddedSyncESEvent failed: Cannot read properties of undefined (reading 'undefined')
at PackageSearchService.syncPackage (file:///home/admin/application/app/core/service/PackageSearchService.ts:93:45)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at PackageVersionAddedSyncESEvent.syncPackage (file:///home/admin/application/app/core/event/SyncESPackage.ts:29:5)
at PackageVersionAddedSyncESEvent.handle (file:///home/admin/application/app/core/event/SyncESPackage.ts:53:5)
at EventHandlerFactory.handle (file:///home/admin/application/node_modules/_@eggjs_tegg-eventbus-runtime@4.0.0-beta.4@@eggjs/tegg-eventbus-runtime/src/EventHandlerFactory.ts:49:7)
at file:///home/admin/application/node_modules/_@eggjs_tegg-eventbus-runtime@4.0.0-beta.4@@eggjs/tegg-eventbus-runtime/src/SingletonEventBus.ts:151:13
at async Promise.all (index 2)
at file:///home/admin/application/node_modules/_@eggjs_tegg-eventbus-runtime@4.0.0-beta.4@@eggjs/tegg-eventbus-runtime/src/SingletonEventBus.ts:149:9
at EggContextHandler.run (file:///home/admin/application/node_modules/_@eggjs_tegg-plugin@4.0.0-beta.4@@eggjs/tegg-plugin/lib/EggContextHandler.ts:19:12)
at Function.ContextHandler.runInContextCallback (file:///home/admin/application/node_modules/_@eggjs_tegg-plugin@4.0.0-beta.4@@eggjs/tegg-plugin/lib/EggContextHandler.ts:27:14)

PR Dependency Tree

This tree was auto-generated by Charcoal

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling when package version information is missing, reducing the chance of runtime errors and providing clearer warning messages.

@fengmk2 fengmk2 requested review from Copilot, elrrrrrrr and killagu June 26, 2025 08:02
Copy link
Contributor
coderabbitai bot commented Jun 26, 2025

Walkthrough

A check was added to ensure that the latestVersion value exists before accessing it in the package manifest. If latestVersion is missing, a warning is logged, and the assignment of latestManifest is made conditional to prevent runtime errors.

Changes

File Change Summary
app/core/service/PackageSearchService.ts Added conditional check for latestVersion, warning log if missing, and safe assignment logic.

Suggested labels

bug

Poem

In the warren's code, a bug did hop,
Where missing versions made us stop.
Now checks are here, and warnings too,
So searching packages works anew!
🐇✨


📜 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 a45f524 and 83b10a9.

📒 Files selected for processing (1)
  • app/core/service/PackageSearchService.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/core/service/PackageSearchService.ts
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Trag Review
  • GitHub Check: test-mysql57-s3-nfs (22, ubuntu-latest)
  • GitHub Check: test-postgresql-fs-nfs (20, ubuntu-latest)
  • GitHub Check: test-mysql57-s3-nfs (20, ubuntu-latest)
  • GitHub Check: test-postgresql-fs-nfs (22, ubuntu-latest)
  • GitHub Check: test-mysql57-fs-nfs (20, ubuntu-latest)
  • GitHub Check: test-postgresql-fs-nfs (24, ubuntu-latest)
  • GitHub Check: test-mysql57-fs-nfs (24, ubuntu-latest)
  • GitHub Check: test-mysql57-fs-nfs (22, ubuntu-latest)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copilot

This comment was marked as outdated.

Copy link
@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @fengmk2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a potential error that occurs when the latestVersion is missing from a package manifest's dist-tags. It adds a check for this condition and logs a warning message, preventing the application from crashing and providing better debugging information. The code also uses optional chaining to safely access the manifest versions.

Highlights

  • Error Handling: Added a check for when latestVersion is missing in the manifest's dist-tags. A warning log is added to help debug the issue.
  • Manifest Access: The code now safely accesses manifest.versions using optional chaining (?.) to avoid errors when latestVersion is not found.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@fengmk2 fengmk2 enabled auto-merge June 26, 2025 08:03
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b96443 and a45f524.

📒 Files selected for processing (1)
  • app/core/service/PackageSearchService.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: test-mysql57-fs-nfs (24, ubuntu-latest)
  • GitHub Check: test-mysql57-s3-nfs (20, ubuntu-latest)
  • GitHub Check: test-postgresql-fs-nfs (20, ubuntu-latest)
  • GitHub Check: test-mysql57-s3-nfs (22, ubuntu-latest)
  • GitHub Check: test-mysql57-fs-nfs (22, ubuntu-latest)
  • GitHub Check: test-postgresql-fs-nfs (22, ubuntu-latest)
  • GitHub Check: test-postgresql-fs-nfs (24, ubuntu-latest)
  • GitHub Check: test-mysql57-fs-nfs (20, ubuntu-latest)

Copy link
@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request fixes a potential TypeError in PackageSearchService.syncPackage when latestVersion is missing. A check for latestVersion was added, and a warning is logged when it's missing. I suggested returning early from the function to prevent subsequent errors.

Copy link
codecov bot commented Jun 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.34%. Comparing base (5b96443) to head (83b10a9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master     #814    +/-   ##
========================================
  Coverage   95.34%   95.34%            
========================================
  Files         196      196            
  Lines       23686    23694     +8     
  Branches     2159     1945   -214     
========================================
+ Hits        22583    22591     +8     
  Misses       1103     1103            

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

8000

@fengmk2 fengmk2 force-pushed the fix-undefined-PackageSearchService branch from a45f524 to 83b10a9 Compare June 26, 2025 08:07
@fengmk2 fengmk2 requested a review from Copilot June 26, 2025 08:07
Copy link
@Copilot 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 fixes an error scenario where the package's latest version information might be missing from the manifest, preventing a runtime error during event processing.

  • Adds a guard condition to check for the existence of a latest version in the manifest and logs a warning when absent.
  • Uses optional chaining when accessing the package version from manifest.versions.

Copy link
trag-bot bot commented Jun 26, 2025

@trag-bot didn't find any issues in the code! ✅✨

Copy link
trag-bot bot commented Jun 26, 2025

Pull request summary

  • Added a check for the existence of latestVersion before attempting to access manifest.versions.
  • Introduced a warning log to notify when latestVersion is not found, including the package name and available dist-tags.
  • Used optional chaining (?.) when accessing manifest.versions to prevent potential runtime errors if latestVersion is undefined.

Copy link
Member
@elrrrrrrr elrrrrrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fengmk2 fengmk2 added this pull request to the merge queue Jun 26, 2025
Merged via the queue into master with commit bed4778 Jun 26, 2025
14 checks passed
@fengmk2 fengmk2 deleted the fix-undefined-PackageSearchService branch June 26, 2025 09:49
fengmk2 pushed a commit that referenced this pull request Jun 26, 2025
[skip ci]

## [4.7.3](v4.7.2...v4.7.3) (2025-06-26)

### Bug Fixes

* latest version maybe not exists ([#814](#814)) ([bed4778](bed4778))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0