Skip to content

fix: _overwrite_pipeline raises IndexError when a pipeline has zero versions - #326

Open
mittalpk wants to merge 1 commit into
deepset-ai:mainfrom
mittalpk:fix/overwrite-pipeline-empty-versions
Open

fix: _overwrite_pipeline raises IndexError when a pipeline has zero versions#326
mittalpk wants to merge 1 commit into
deepset-ai:mainfrom
mittalpk:fix/overwrite-pipeline-empty-versions

Conversation

@mittalpk

@mittalpk mittalpk commented Aug 7, 2026

Copy link
Copy Markdown

What

_overwrite_pipeline indexed version_body["data"][0] unguarded. The 404 (pipeline doesn't exist) case is handled, but a pipeline that exists with zero saved versions — created but never versioned — returns 200 with an empty data list, and this raised a raw IndexError instead of proceeding.

Fix

Treat an empty versions list the same as "latest version isn't a draft": there's no draft to patch, so it now creates a new version via POST /pipelines/{name}/versions — the same path already used for the non-draft case.

Testing

Added test_import_pipeline_with_overwrite_true_creates_new_version_when_no_versions_exist, mirroring the existing draft/non-draft/404 test cases for this method. Confirmed it fails with the exact IndexError against unpatched code (git stash) and passes after the fix. Full tests/unit/service/test_pipeline_service.py suite: 41 passed. ruff check, ruff format --check, and mypy (Python 3.10, matching this repo's configured python_version) all clean.

…ersions

version_body["data"][0] was unguarded in _overwrite_pipeline. The
404 case (pipeline doesn't exist) was handled, but a pipeline that
exists with zero saved versions -- created but never versioned --
returns 200 with an empty data list, and the unguarded index raised
IndexError instead of falling through to any of the method's other
branches.

Treat an empty versions list the same as "latest version isn't a
draft": there's no draft to patch, so create a new version via
POST /pipelines/{name}/versions, same endpoint already used for
that case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant