Skip to content

fix: prevent unhandled AssertionError in PipelineBase.__eq__ when comparing to non-Pipeline types - #12387

Merged
sjrl merged 1 commit into
deepset-ai:mainfrom
rautaditya2606:fix-pipeline-base-eq
Aug 20, 2026
Merged

sjrl merged 1 commit into
deepset-ai:mainfrom
rautaditya2606:fix-pipeline-base-eq

Conversation

@rautaditya2606

Copy link
Copy Markdown
Contributor

Related Issues

Closes #12386

Proposed Changes

  • Corrected the inverted check if not isinstance(self, type(other)) to if not isinstance(other, type(self)) in PipelineBase.__eq__.
  • Removed the redundant assert isinstance(other, PipelineBase) check.
  • Added regression tests covering equality of identical pipelines, comparison against non-Pipeline objects (e.g. object(), strings, ints, None, and list membership), and subclass comparisons.
  • Added release note in releasenotes/notes/fix-pipeline-base-eq-a665ea11824f86fb.yaml.

How did you test it?

hatch run test:unit test/core/pipeline/test_pipeline_base.py

154 passed, 2 deselected in 4.56s.

Notes for the reviewer

  • Root cause: PipelineBase.__eq__ previously checked isinstance(self, type(other)) instead of isinstance(other, type(self)). When a Pipeline instance was compared against any object whose type is a superclass of Pipeline (such as object()), isinstance(self, object) evaluated to True. This bypassed the early return and hit assert isinstance(other, PipelineBase), raising an unhandled AssertionError.

  • In Python, __eq__ must return False (or NotImplemented) when comparing incompatible types and never raise an AssertionError.

  • Reproducer:

    from haystack import Pipeline
    
    pipeline = Pipeline()
    
    # Before fix -> raises AssertionError
    # After fix  -> False
    pipeline == object()
    pipeline in [object(), "other_type"]
  • The fix ensures PipelineBase.__eq__ adheres to Python's data model contract for equality comparisons.

Checklist

  • Read contributors guidelines and code of conduct
  • Updated related issue
  • Added unit tests and updated docstrings
  • Used conventional commit type in PR title
  • Documented code
  • Added release note (releasenotes/notes/fix-pipeline-base-eq-a665ea11824f86fb.yaml)
  • Run pre-commit hooks and fixed any issues

Copilot AI lite review requested due to automatic review settings August 17, 2026 19:04
@rautaditya2606
rautaditya2606 requested a review from a team as a code owner August 17, 2026 19:04
@rautaditya2606
rautaditya2606 requested review from julian-risch and removed request for a team August 17, 2026 19:04

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

@rautaditya2606 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/core/pipeline
  base.py
Project Total  

This report was generated by python-coverage-comment-action

@sjrl sjrl left a comment

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.

Thanks!

@sjrl
sjrl merged commit 39ef21a into deepset-ai:main Aug 20, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PipelineBase.__eq__ raises AssertionError when comparing against non-Pipeline objects

3 participants