Skip to content

_format_exception() duplicates message when cause text is already embedded #1243

Description

@LalatenduMohanty

Bug description

Expected behavior:
Error messages should not repeat the same information.

Actual behavior:
resolver.py:286-288 wraps exceptions with raise ResolverException(f"...{original_msg}") from err — embedding the cause's text in the outer message AND chaining it as __cause__. When __main__._format_exception() formats this, it appends " because {cause}", producing a duplicated message:

Unable to resolve requirement specifier flashinfer-python==0.6.8.post1
  with constraint flashinfer-python==0.6.11.post2: found no match for
  flashinfer-python==0.6.8.post1 because found no match for
  flashinfer-python==0.6.8.post1

The " because found no match..." portion is redundant — the same text already appears after the colon.

Steps to reproduce:
Trigger any resolution failure where find_all_matching_from_provider() wraps a ResolverException with from err (the common case for constraint conflicts or missing packages).

Proposed fix

Add a dedup check in _format_exception(): when the outer exception's message already starts with the cause's raw message (str(exc.__cause__)), skip the " because ..." clause. A startswith check matches the actual construction pattern (f"...{original_msg}") without false-positiving on coincidental substrings.

This was originally part of #1241 but is being split out as an independent fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions