Skip to content

Non actionable error message #15765

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

ojuschugh1
Copy link

What does this PR try to resolve?

This PR improves the error reporting experience when running cargo publish on a workspace. Previously, if publishing failed partway through (for example, due to rate limiting or a server error), Cargo would emit a non-actionable error message that did not indicate which package failed or which packages were still pending publication. This made it difficult for users to recover from errors or know what steps to take next.

This PR addresses issue #15754 by:

  • Clearly indicating which specific package failed to publish.
  • Listing which packages in the workspace have not yet been published.
  • Providing actionable, user-friendly error messages to help users understand what went wrong and what remains to be done.

How to test and review this PR?

Testing:

  • New and updated tests are included in tests/testsuite/publish.rs:
    • The tests simulate workspace publishing scenarios where errors occur (such as rate limiting or server errors).
    • The tests verify that error messages now include:
      • The name of the package that failed to publish.
      • A list of remaining packages that still need to be published.
      • Clear guidance on what happened.
  • To run the tests:
    cargo test workspace_publish_error_reporting
    cargo test workspace_transmit_error_includes_remaining_packages
    cargo test transmit_error_includes_package_name
  • All existing tests continue to pass, ensuring no regressions.

Review Guidance:

  • Review the changes in src/cargo/ops/registry/publish.rs for error context enhancements and message formatting.
  • Review the new and updated tests in tests/testsuite/publish.rs to see how error scenarios are simulated and validated.
  • Try running cargo publish on a workspace with multiple packages and simulate a failure (e.g., by using a test registry or causing a network error) to see the improved error output in action.

Example improved error message:

error: failed to publish to registry at https://crates.io
Package: my-package

Caused by:
  the remote server responded with an error (status 429 Too Many Requests): You have published too many new crates in a short period of time. Please try again after Fri, 18 Jul 2025 20:00:34 GMT or email help@crates.io to have your limit increased.

Remaining packages to publish: other-package-1, other-package-2, other-package-3

Summary:
This PR makes workspace publishing failures much more actionable and user-friendly, helping users quickly identify what went wrong and what steps to take next. All changes are covered by tests and follow Cargo’s contribution guidelines.

This test demonstrates current inadequate error behavior when workspace
publishing fails. Users don't know which package failed or which packages
are still pending publication.
When a package fails to publish, the error message now includes
the package name to help users identify which package failed.

This improves error reporting by providing clear context about
which specific package encountered the error.
When a package fails to publish during workspace publishing,
the error message now includes a list of remaining packages
that have not been published yet.

This helps users understand the full scope of what still needs
to be published after a failure occurs.
Updated the workspace publish error reporting test to reflect
the improved error messages that now include package names
and remaining unpublished packages.

The test verifies that both timeout scenarios and transmit
failures provide clear, actionable error messages to users.
@rustbot rustbot added A-interacts-with-crates.io Area: interaction with registries Command-publish labels Jul 22, 2025
@ojuschugh1 ojuschugh1 marked this pull request as ready for review July 22, 2025 18:49
@rustbot
Copy link
Collaborator

rustbot commented Jul 22, 2025

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 22, 2025
@ojuschugh1 ojuschugh1 requested a review from epage July 22, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-interacts-with-crates.io Area: interaction with registries Command-publish S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants