Skip to content

fix(config): show invalid date in release hint warnings - #5208

Open
reidliu41 wants to merge 1 commit into
rust-lang:mainfrom
reidliu41:fix/release-date-error-context
Open

reidliu41 wants to merge 1 commit into
rust-lang:mainfrom
reidliu41:fix/release-date-error-context

Conversation

@reidliu41

Copy link
Copy Markdown

When the installed stable manifest contains a date that cannot be parsed, the release hint warning prints the literal {release_date_str} placeholder:

warn: could not check if there is a new Rust release: could not parse release date '{release_date_str}'

This hides the invalid value and makes damaged or custom manifests harder to diagnose.

@djc

djc commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

(Adding 39 lines worth of test feels like overkill to me.)

Comment thread tests/suite/cli_rustup.rs
.expect(["rustup", "toolchain", "list"])
.await
.with_stderr(snapbox::str![[r#"
warn: could not check if there is a new Rust release: could not parse release date 'not-a-date'

@rami3l rami3l Nov 10, 2026 •

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.

@djc Didn't this introduce a new attack vector? I mean in a similar fashion to #4059 where you can essentially do:

warn: could not check if there is a new Rust release: could not parse release date '

<many random lines so that the above warning becomes hard to find>
<some random output to confuse the user>

warn: your Rust installation is broken
hint: to attempt a fix, please execute
    <ACE payload>'

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, that might be true. We could constrain the length to, say, 60 characters, and make sure it doesn't contain any newlines?

@rami3l rami3l Nov 10, 2026 •

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.

Good idea! IMHO 15 characters actually would make more sense since it's mostly yyyy-mm-dd.

cc @reidliu41

Comment thread src/config.rs
Ok(Some(manifest)) => manifest.date,
Ok(None) | Err(_) => FALLBACK_RELEASE_DATE.to_owned(),
},
Err(_) => FALLBACK_RELEASE_DATE.to_owned(),

@FranciscoTGouveia FranciscoTGouveia Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When the manifest is missing or unreadable, we have FALLBACK_RELEASE_DATE.
Shouldn't we have something similar when there is a parsing error?

So, besides throwing the error, we would call NaiveDate::parse_from_str(FALLBACK_RELEASE_DATE, "%Y-%m-%d").

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

On another note, this FALLBACK_RELEASE_DATE should be updated every time there is a new rustup release; although that sounds cumbersome.

This branch has not been deployed

No deployments
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.

4 participants