Skip to content

fix: raise on attempt to change immutable vector index type (#1277)#2080

Open
shaikn6 wants to merge 1 commit into
weaviate:mainfrom
shaikn6:fix/issue-1277-immutable-vector-index-type
Open

fix: raise on attempt to change immutable vector index type (#1277)#2080
shaikn6 wants to merge 1 commit into
weaviate:mainfrom
shaikn6:fix/issue-1277-immutable-vector-index-type

Conversation

@shaikn6

@shaikn6 shaikn6 commented Jun 25, 2026

Copy link
Copy Markdown

What & why

Fixes #1277.

collection.config.update(...) silently ignored attempts to change a collection's vector index type (e.g. flathnsw/dynamic). The vector index type is immutable server-side, but the client neither applied the change nor reported an error, so users believed the reconfiguration had taken effect when it had not.

Root cause

In _CollectionConfigUpdate.merge_with_existing the vector-index update branches merged the new vectorIndexConfig into the existing schema without validating the requested index type:

  • Legacy single vector (vector_index_config / vectorizer_config): the config keys were merged but the top-level schema["vectorIndexType"] was never touched — a silent no-op (the exact reproduction in the issue).
  • Named vectors (vectorizer_config list / vector_config): vectorIndexType was overwritten with the requested type without the required server-side reindex, mislabeling the index.

The fix

A new helper __check_vector_index_type compares the requested vector_index_type() against the existing schema's type and raises WeaviateInvalidInputError when they differ. It is invoked in all three update paths before merging:

weaviate.exceptions.WeaviateInvalidInputError: Cannot update the vector index type of a
collection from 'flat' to 'dynamic'. The vector index type is immutable. To change it you
must recreate the collection with the desired vector index type and reindex its objects.

Same-type updates (e.g. tuning ef on an existing HNSW index) continue to work unchanged. No public API signatures change, so the generated .pyi stubs are unaffected.

Testing

Added unit tests in test/collection/test_config_update.py (operating on merge_with_existing, no live Weaviate server required):

  • test_changing_vector_index_type_single_vector_raises — reproduces Throw error message when trying to update vector index type configuration in a collection #1277 (flat → dynamic raises)
  • test_changing_vector_index_type_via_vector_index_config_raises — deprecated vector_index_config arg also raises
  • test_changing_vector_index_type_named_vector_raises / test_changing_vector_index_type_vector_config_raises — named-vector paths raise
  • test_same_vector_index_type_single_vector_still_updates / test_same_vector_index_type_named_vector_still_updates — allowed same-type updates still merge correctly

Verified the new "should raise" tests fail on main without the source change (DID NOT RAISE) and pass with it.

Ran locally (Python 3.12):

  • pytest test/collection/287 passed, 1 skipped (the unrelated test_validator.py collection error is only due to optional heavy deps numpy/pandas/polars not installed in my minimal venv; it does not touch this change)
  • ruff format --check → clean
  • flake8 → clean
  • pyright → no errors in config.py (the 4 pre-existing connect/v4.py authlib errors are present on unmodified main)
  • pydoclint → no new findings for the added method

CLA

Per CONTRIBUTING.md, contributions require a Contributor License Agreement (signed via the DocuSign link that the bot posts on the PR). I will sign it once it appears.

…#1277)

`collection.config.update(...)` previously ignored attempts to change a
collection's vector index *type* (e.g. flat -> hnsw/dynamic). The new
config was merged into the existing schema, but the index type is
server-side immutable: for the legacy single-vector path the
`vectorIndexType` was left untouched (a silent no-op), and for named
vectors the type label was overwritten without the required reindex.
Either way the user wrongly believed the change had been applied.

`_CollectionConfigUpdate.merge_with_existing` now compares the requested
`vector_index_type()` against the existing schema across all three update
paths (`vector_index_config`, `vectorizer_config`, and `vector_config`)
and raises `WeaviateInvalidInputError` with a clear message explaining
that the type is immutable and the collection must be recreated and
reindexed to change it.

Adds unit tests in `test/collection/test_config_update.py` asserting the
raise for single and named vectors and that same-type updates still merge
successfully.

Fixes weaviate#1277

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@weaviate-git-bot

Copy link
Copy Markdown

To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Forum?

@shaikn6

shaikn6 commented Jun 25, 2026

Copy link
Copy Markdown
Author

To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.beep boop - the Weaviate bot 👋🤖PS:Are you already a member of the Weaviate Forum?

yes, I agree with the CLA

@shaikn6

shaikn6 commented Jun 25, 2026

Copy link
Copy Markdown
Author

you agree with the CLA

@shaikn6

shaikn6 commented Jun 25, 2026

Copy link
Copy Markdown
Author

I have read and agree to the Weaviate Contributor License Agreement.

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.

Throw error message when trying to update vector index type configuration in a collection

2 participants