Skip to content

Fix Non-actionable error messages #15799

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 4 commits into
base: master
Choose a base branch
from

Conversation

ojuschugh1
Copy link
Contributor

@ojuschugh1 ojuschugh1 commented Aug 1, 2025

What does this PR try to resolve?

This PR fixes issue #15754 by improving error reporting for workspace publish failures.
Previously, when publishing a workspace, if one package failed (e.g., due to an existing version), Cargo did not clearly list which packages failed and which remained unpublished.
This change ensures that the error message now includes both the failed package and any remaining unpublished packages, making it easier for users to understand what went wrong and what still needs to be published.


How to test and review this PR?

  • A new test (workspace_publish_failure_reports_remaining_packages) was added to publish.rs to demonstrate the previous behavior and verify the fix.
  • The test first fails with the old behavior, then passes after the fix is applied.
  • All commits are split for clarity: the test is added first, then the implementation is updated.
  • To review:
    1. Check that the new test covers the relevant error scenario.
    2. Review the implementation changes in publish.rs for error context propagation.
    3. Confirm that all tests pass (SNAPSHOTS=overwrite cargo test).
    4. Review commit-by-commit for a clear history.

How to test locally:

SNAPSHOTS=overwrite cargo test --test testsuite publish::workspace_publish_failure_reports_remaining_packages

or simply

SNAPSHOTS=overwrite cargo test

or

cargo test

to run the full suite.


@rustbot rustbot added A-interacts-with-crates.io Area: interaction with registries Command-publish labels Aug 1, 2025
@ojuschugh1
Copy link
Contributor Author

ojuschugh1 commented Aug 1, 2025

What does this PR try to resolve?

This PR fixes issue #15754 by improving error reporting for workspace publish failures. Previously, when publishing a workspace, if one package failed (e.g., due to an existing version), Cargo did not clearly list which packages failed and which remained unpublished. This change ensures that the error message now includes both the failed package and any remaining unpublished packages, making it easier for users to understand what went wrong and what still needs to be published.

How to test and review this PR?

* A new test (`workspace_publish_failure_reports_remaining_packages`) was added to publish.rs to demonstrate the previous behavior and verify the fix.

* The test first fails with the old behavior, then passes after the fix is applied.

* All commits are split for clarity: the test is added first, then the implementation is updated.

* To review:
  
  1. Check that the new test covers the relevant error scenario.
  2. Review the implementation changes in publish.rs for error context propagation.
  3. Confirm that all tests pass (`SNAPSHOTS=overwrite cargo test`).
  4. Review commit-by-commit for a clear history.

How to test locally:

SNAPSHOTS=overwrite cargo test --test testsuite publish::workspace_publish_failure_reports_remaining_packages

or simply

SNAPSHOTS=overwrite cargo test

or

cargo test

to run the full suite.

This PR also solves the feedback received on my old fix -: #15791

New Changes include-: 1) All commits are atomic and passed cargo test.
2) Solved the Port Number issue by falling back to [..].
3) Removed verify step runs BEFORE any packages are published since nothing is published at that point so no need for it.

@ojuschugh1 ojuschugh1 marked this pull request as ready for review August 1, 2025 16:26
@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 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 Aug 1, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

Same feedback as #15791 (comment)

This commit should be able to pass as-is but it can't because its including test changes for the following commit

Copy link
Contributor

Choose a reason for hiding this comment

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

refactor: clean up publish error context and remove unused variables

Note that a "refactor" means a change to the code with no user-visible impact. If you wish to use Conventional Commits, this would be better term a fix

Also, the commit title talks about cleanup and removing a variable but the commit is about adding extra context to error messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will fix this commit title , first i wanted to complete the implementation in this pr, I will open a new pr with proper final fixes and commits. So that the git history should be clean

Comment on lines 2366 to 2369
[ERROR] failed to publish `foo` v0.0.1

Caused by:
failed to publish to registry at http://127.0.0.1:[..]/
Copy link
Contributor

Choose a reason for hiding this comment

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

#15791 (comment) is not resolved

Why are we reporting two failed to publish messages? Shouldn't we just put all of this information in the one failed to publish message?

Copy link
Contributor

Choose a reason for hiding this comment

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

From @ojuschugh1 at https://github.com/rust-lang/cargo/pull/15799/files#r2252608902

Hi @epage so regarding this https://github.com/rust-lang/cargo/pull/15799/files#r2252499850 , I found out that already in some places like here there are more than one failed to publish messages so i thought to keep like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you clarify what you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi , @epage We show two lines because Cargo prints the error chain: the top-level is a workspace-specific summary (which crate failed + what’s left), and the “Caused by” line is the transport/server detail. This keeps it readable and preserves single-crate behavior. If you prefer one line, I can collapse it and update tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we extend the original error to include the context? Seems like that would provide much better results.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will try to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@epage , I have fixed this. Kindly please review and let me know, if anything else you want me to do.

@ojuschugh1 ojuschugh1 marked this pull request as draft August 21, 2025 19:34
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 21, 2025
…failure

- Keep single-crate error format unchanged
- Add test for workspace failure messaging
@ojuschugh1 ojuschugh1 marked this pull request as ready for review August 21, 2025 20:04
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 21, 2025
Avoid duplicate "failed to publish" text by combining workspace info with original error message.
Fixes rust-lang#15754.
@weihanglo
Copy link
Member

Could you edit the title to make it clearer what this is about at first glance?
(Yeah maintainer can surely do that though, just being nice if you want to edit your stuff)

@ojuschugh1
Copy link
Contributor Author

Could you edit the title to make it clearer what this is about at first glance? (Yeah maintainer can surely do that though, just being nice if you want to edit your stuff)

Sure no issues

@ojuschugh1 ojuschugh1 changed the title 15754 Fix Non-actionable error messages Aug 22, 2025
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.

Non-actionable error message when publish fails in the middle of a worskpace
4 participants