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

[cli] Better error message when a sui config folder exists without genesis metadata #19487

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

stefan-mysten
Copy link
Contributor

Description

Improves the error message when running sui start when a sui config folder exists without genesis metadata.

Test plan

Existing tests.


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):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI: Improved the error message when running sui start when a sui config folder exists without genesis metadata.
  • Rust SDK:
  • REST API:

@stefan-mysten stefan-mysten requested review from damirka and a team September 21, 2024 21:44
@stefan-mysten stefan-mysten self-assigned this Sep 21, 2024
Copy link

vercel bot commented Sep 21, 2024

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Sep 21, 2024 9:45pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Sep 21, 2024 9:45pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Sep 21, 2024 9:45pm

@@ -631,7 +631,7 @@ async fn start(
swarm_builder = swarm_builder.with_epoch_duration_ms(epoch_duration_ms);
} else {
if config.is_none() && !sui_config_dir()?.join(SUI_NETWORK_CONFIG).exists() {
genesis(None, None, None, false, epoch_duration_ms, None, false).await?;
genesis(None, None, None, false, epoch_duration_ms, None, false).await.map_err(|_| anyhow!("Cannot run genesis with non-empty Sui config directory: {}.\n\nIf you are trying to run a local network without persisting the data (so a new genesis that is randomly generated and will not be saved once the network is shut down), use --force-regenesis flag.\nIf you are trying to persist the network data and start from a new genesis, use sui genesis --help to see how to generate a new genesis.", sui_config_dir().unwrap().display()))?;
Copy link
Member

Choose a reason for hiding this comment

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

What's the error message this used to produce? Usually it's better to use context(...) to add extra information to the existing error message rather than entirely replace it, but maybe the existing error message doesn't help here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error message that would show is the one for genesis command. The issue is that genesis command has some extra flags (e.g., --force), which we should not add here, so when that error message gets propagated here it does not make sense.
I think it's better to provide a specific error message here given this situation.
For some reason that I do not know, I've never been a fan of context 😅

Copy link
Member

Choose a reason for hiding this comment

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

I think in a CLI setting it may not be great, it tends to work pretty well for errors coming from a service, where you can want to share a logical "call stack".

@stefan-mysten stefan-mysten merged commit 283f954 into MystenLabs:main Sep 23, 2024
42 of 43 checks passed
@stefan-mysten stefan-mysten deleted the cli_fix_start_message branch September 23, 2024 16:46
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