Skip to content

fix: reject bool values in ConnectionConfig int validators (Fixes #2076)#2077

Merged
dirkkul merged 1 commit into
weaviate:mainfrom
rtmalikian:fix/issue-2076-bool-in-config-validation
Jun 24, 2026
Merged

fix: reject bool values in ConnectionConfig int validators (Fixes #2076)#2077
dirkkul merged 1 commit into
weaviate:mainfrom
rtmalikian:fix/issue-2076-bool-in-config-validation

Conversation

@rtmalikian

Copy link
Copy Markdown
Contributor

Fixes #2076

Problem

In weaviate/config.py, the ConnectionConfig.__post_init__ method validates that session_pool_connections, session_pool_maxsize, session_pool_max_retries, and session_pool_timeout are int types using isinstance(x, int).

Since bool is a subclass of int in Python, isinstance(True, int) returns True. This means True and False silently pass validation for these fields:

from weaviate.config import ConnectionConfig
config = ConnectionConfig(session_pool_connections=True)  # No error!
config.session_pool_connections  # True (not a valid connection count)

The same pattern exists in weaviate/util.py's check_number() helper function.

Solution

Add and not isinstance(x, bool) guard to all four validators in ConnectionConfig.__post_init__ and to the check_number() helper in util.py.

Verification

# Before fix: True passes validation
ConnectionConfig(session_pool_connections=True)  # No error

# After fix: True is rejected
ConnectionConfig(session_pool_connections=True)  # TypeError

# Normal int values still work
ConnectionConfig(session_pool_connections=20)  # OK

Changelog

Date Change Author
2026-06-20 Add bool guard to ConnectionConfig int validators and check_number() rtmalikian

Files Changed

  • weaviate/config.py — Add or isinstance(x, bool) to all 4 int validators
  • weaviate/util.py — Add bool guard to check_number() helper

About the Author: Raphael Malikian — Clinical AI Solutions Architect. I specialise in building and fixing AI/ML systems for healthcare, including vector databases, RAG pipelines, and clinical NLP. If you need help with your project or think I can add value to your organisation, feel free to reach out — I'd love to connect.

📧 rtmalikian@gmail.com
🔗 GitHub: https://github.com/rtmalikian
🔗 LinkedIn: http://www.linkedin.com/in/raphael-t-malikian-mbbs-bsc-hons-71075436a


Disclosure: This code was developed with assistance from mimo-v2.5-pro (Xiaomi) via Hermes Agent (Nous Research). All changes were reviewed, tested against the actual codebase, and verified for correctness.

Python's bool is a subclass of int, so isinstance(True, int) returns
True. This allowed True/False to pass validation for session pool
settings (connections, maxsize, retries, timeout).

Add 'and not isinstance(x, bool)' guard to all four validators in
ConnectionConfig.__post_init__ and to the check_number() helper in
util.py.

Fixes weaviate#2076

Signed-off-by: rtmalikian <rtmalikian@gmail.com>

@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?

@rtmalikian

Copy link
Copy Markdown
Contributor Author

I agree with the CLA. Thank you!

@dirkkul dirkkul merged commit 17a9887 into weaviate:main Jun 24, 2026
123 of 125 checks passed
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.

bug: isinstance(int) validators in ConnectionConfig accept bool values

3 participants