Skip to content

Improve trusted publishing error message #11389

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

Merged
merged 1 commit into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/controllers/krate/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ pub async fn publish(app: AppState, req: Parts, body: Body) -> AppResult<Json<Go

let auth = if let Some(trustpub_token) = trustpub_token {
let Some(existing_crate) = &existing_crate else {
let error = forbidden("Trusted Publishing tokens do not support creating new crates");
let error = forbidden(
"Trusted Publishing tokens do not support creating new crates. Publish the crate manually, first",
);
return Err(error);
};

Expand Down
2 changes: 1 addition & 1 deletion src/tests/krate/publish/trustpub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ async fn test_non_existent_token_with_new_crate() -> anyhow::Result<()> {
let pb = PublishBuilder::new("foo", "1.0.0");
let response = oidc_token_client.publish_crate(pb).await;
assert_snapshot!(response.status(), @"403 Forbidden");
assert_snapshot!(response.text(), @r#"{"errors":[{"detail":"Trusted Publishing tokens do not support creating new crates"}]}"#);
assert_snapshot!(response.text(), @r#"{"errors":[{"detail":"Trusted Publishing tokens do not support creating new crates. Publish the crate manually, first"}]}"#);

Ok(())
}
Expand Down