fix: _overwrite_pipeline raises IndexError when a pipeline has zero versions - #326
Open
mittalpk wants to merge 1 commit into
Open
fix: _overwrite_pipeline raises IndexError when a pipeline has zero versions#326mittalpk wants to merge 1 commit into
mittalpk wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
_overwrite_pipelineindexedversion_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 — returns200with an emptydatalist, and this raised a rawIndexErrorinstead 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 exactIndexErroragainst unpatched code (git stash) and passes after the fix. Fulltests/unit/service/test_pipeline_service.pysuite: 41 passed.ruff check,ruff format --check, andmypy(Python 3.10, matching this repo's configuredpython_version) all clean.