Skip to content
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

Fix ModuleDB reporting wrong path when transient dependency cannot find the correct import #564

Merged
merged 3 commits into from
Jan 15, 2025

Conversation

lynzrand
Copy link
Collaborator

@lynzrand lynzrand commented Jan 15, 2025

Consider the following package structure:

Module user/transient:
  Package user/transient/lib:
    depends user/transient/nonexistant;

Module user/main:
  depends user/trainsint;

  Package user/main:
    depends user/transient/lib;

There is an non-existant package dependency at user/transient/lib. Currently, the error will be noticed by moonbuild, but the error was reported using the relative path of the error package, but rooted at SOURCE_PATH, i.e. user/main/lib (a non-existant file). This PR corrects the behavior by reporting the error in the correct place, user/transient/lib.

Related Issues

  • Related issues: #____

Type of Pull Request

  • Bug fix
  • New feature
    • I have already discussed this feature with the maintainers.
  • Refactor
  • Performance optimization
  • Documentation
  • Other (please describe):

Does this PR change existing behavior?

  • Yes (please describe the changes below)
    • Corrected the output message
  • No

Does this PR introduce new dependencies?

  • No
  • Yes (please check binary size changes)

Checklist:

  • Tests added/updated for bug fixes or new features
  • Compatible with Windows/Linux/macOS

Copy link

peter-jerry-ye-code-review bot commented Jan 15, 2025

‼️ This code review is generated by a bot. Please verify the content before trusting it.

Here are three observations from the git diff output:

  1. Missing Newline at End of File:

    • In the file nonexistent_package.in/README.md, there is no newline at the end of the file. This is indicated by the \ No newline at end of file comment. While this is not a bug, it is generally considered good practice to include a newline at the end of files to avoid potential issues with certain tools and version control systems.
  2. Inconsistent Error Message Formatting:

    • In the test_nonexistent_package test case, the error messages in the expect! macro are formatted with $ROOT as a placeholder. However, the actual error messages in the code (in crates/moonutil/src/module.rs) do not use $ROOT. This inconsistency could lead to confusion or mismatches between expected and actual error messages. Ensure that the test expectations align with the actual error message format.
  3. Potential Redundant Code:

    • In crates/moonutil/src/module.rs, the error message formatting was simplified by replacing a more complex path construction with pkg.root_path.join(MOON_PKG_JSON).display(). While this is a good simplification, ensure that pkg.root_path is always correctly set and points to the intended directory. If pkg.root_path is not properly initialized, this change could introduce bugs.

These observations should be reviewed and addressed to ensure code quality and consistency.

@lynzrand lynzrand force-pushed the rynco/nonexisting-package-error branch from 43e9797 to a60a76c Compare January 15, 2025 03:14
@lynzrand lynzrand requested review from lijunchen and Young-Flash and removed request for lijunchen January 15, 2025 03:14
@lynzrand lynzrand force-pushed the rynco/nonexisting-package-error branch from a60a76c to 46c7b2d Compare January 15, 2025 03:24
@Young-Flash Young-Flash force-pushed the rynco/nonexisting-package-error branch from 46c7b2d to 388acc0 Compare January 15, 2025 07:52
@Young-Flash Young-Flash enabled auto-merge January 15, 2025 07:52
@Young-Flash Young-Flash merged commit 7fb389a into main Jan 15, 2025
14 checks passed
@Young-Flash Young-Flash deleted the rynco/nonexisting-package-error branch January 15, 2025 08:00
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