Skip to content

Emit more specific popup for metadata fail with cairo version mismatch - #1331

Open
maciektr wants to merge 1 commit into
mainfrom
maciektr/cairo-version-fail
Open

Emit more specific popup for metadata fail with cairo version mismatch#1331
maciektr wants to merge 1 commit into
mainfrom
maciektr/cairo-version-fail

Conversation

@maciektr

Copy link
Copy Markdown
Collaborator

The cairo-version field in manifest may require different scarb/cairo toolchain version than currently available. In this case, emit a more specific popup instead of generic "metadata failed" error

@maciektr
maciektr requested a review from a team as a code owner June 10, 2026 12:06
@maciektr
maciektr requested review from Arcticae and wawel37 and removed request for a team June 10, 2026 12:06
Comment thread src/toolchain/scarb.rs
}

pub fn notify_metadata_failed(&self) {
pub fn notify_metadata_failed(&self, message: &str) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the function no longer signals only failed metadata

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't think I understand what you are trying to say 🤔 Invalid cairo is still a metadata fail.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I mean read what the code does right now - it doesn't send metadata failure message. It sends any message you pass it

Comment thread src/toolchain/scarb.rs
pub const SCARB_TOML: &str = "Scarb.toml";
pub const SCARB_METADATA_FAILED_MESSAGE: &str =
"`scarb metadata` failed. Check if your project builds correctly via `scarb build`.";
pub const SCARB_METADATA_CAIRO_VERSION_MISMATCH_MESSAGE: &str = "`scarb metadata` failed due to a Cairo version requirement mismatch. The Cairo version \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it's not used in this file, it shouldn't be here probably

}

fn scarb_metadata_message_is_cairo_version_mismatch(message: &ScarbMetadataMessage) -> bool {
match message {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[nit]: i'd rather have if let chain here

///
/// When the failure is caused by a Cairo version requirement mismatch, returns a dedicated
/// message pointing the user at the root cause instead of the generic one.
pub fn scarb_metadata_failed_message(messages: &[ScarbMetadataMessage]) -> &'static str {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ScarbMetadataMessage prescence doesn't mean that a metadata failed - it can contain diagnostics only which are non fatal. this function can easily lead to misunderstanding of the metadata internals

Comment thread src/project/mod.rs
// always inform the user with a popup - the message is tailored to the
// cause (e.g. a Cairo version mismatch) when we can recognize it.
// Located manifest diagnostics are additionally surfaced inline.
self.scarb_toolchain.notify_metadata_failed(scarb_metadata_failed_message(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can probably be done easily inside metadata, exposed in invocation result somehow and not leak metadata handling logic outside to project layer.

if messages.iter().any(scarb_metadata_message_is_cairo_version_mismatch) {
SCARB_METADATA_CAIRO_VERSION_MISMATCH_MESSAGE
} else {
SCARB_METADATA_FAILED_MESSAGE

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct me if im wrong, but not all metadata messages are strictly "fails".

Comment thread src/toolchain/scarb.rs
Comment on lines 18 to +20
pub const SCARB_METADATA_FAILED_MESSAGE: &str =
"`scarb metadata` failed. Check if your project builds correctly via `scarb build`.";
pub const SCARB_METADATA_CAIRO_VERSION_MISMATCH_MESSAGE: &str = "`scarb metadata` failed due to a Cairo version requirement mismatch. The Cairo version \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: i'd move those 2 to scarb_manifest_diagnostics

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