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

Format missing module errors in upgrade errors #20541

Conversation

jordanjennings-mysten
Copy link
Contributor

@jordanjennings-mysten jordanjennings-mysten commented Dec 6, 2024

Description

Missing modules errors do not have a file to point to since their file has been removed during upgrade or otherwise unknown since the declaration is gone from its previous file if the file still exists. Align missing modules errors with the behavior of other errors by using Move.toml as the reference point for these errors and pointing to the "package" instead.

Test plan

snapshots


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

Copy link

vercel bot commented Dec 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2024 0:09am
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Dec 21, 2024 0:09am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Dec 21, 2024 0:09am
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Dec 21, 2024 0:09am

Copy link
Member

@amnn amnn left a comment

Choose a reason for hiding this comment

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

I'm pretty happy with this change, modulo the question about trying to avoid returning an Err(...) instead of the diagnostic. It would be good to get @tnowacki's take on things, because he's more the expert in this area than me, but after that, I think this is good to go!

crates/sui/src/upgrade_compatibility.rs Outdated Show resolved Hide resolved
crates/sui/src/upgrade_compatibility.rs Outdated Show resolved Hide resolved
Comment on lines 832 to 838
let toml_path = package_path.join("Move.toml");
let toml_str = fs::read_to_string(&toml_path).context("Unable to read Move.toml")?;
let hash = FileHash::new(&toml_str);

let start: usize = toml_str
.find(PACKAGE_TABLE)
.context("Malformed Move.toml")?;
Copy link
Member

Choose a reason for hiding this comment

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

It looks like if we fail to read the Move.toml we may end up hiding all the other diagnostics. Do you think it would be possible for us to always produce some kind of Diagnostics value, even if we failed to read the Move.toml to avoid that?

Copy link
Contributor Author

@jordanjennings-mysten jordanjennings-mysten Dec 10, 2024

Choose a reason for hiding this comment

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

I was thinking this more as a "critical" error since a build shouldn't be possible however I think it could be good to just let this return a diagnostic for byte ranges 0,0 as a fallback. Some errors I'd guess will just fall in that "critical" category and should be errored out but we could potentially discuss follow up work to prevent errors from stopping execution by converting Errors -> Diags. Or alternatively just maintain a list of errors and print them last / concatenate them into a single error that is thrown last.

crates/sui/src/upgrade_compatibility.rs Outdated Show resolved Hide resolved
@jordanjennings-mysten jordanjennings-mysten temporarily deployed to sui-typescript-aws-kms-test-env December 20, 2024 00:09 — with GitHub Actions Inactive
@jordanjennings-mysten jordanjennings-mysten force-pushed the missing-module-error-formatting branch from 783feae to 5400241 Compare December 21, 2024 00:08
@jordanjennings-mysten jordanjennings-mysten temporarily deployed to sui-typescript-aws-kms-test-env December 21, 2024 00:08 — with GitHub Actions Inactive
@jordanjennings-mysten jordanjennings-mysten merged commit f321519 into MystenLabs:main Dec 21, 2024
49 of 50 checks passed
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.

3 participants