Skip to content

Fix typo in Visitor._validate_func error message for operators #36701

@eye-gu

Description

@eye-gu

Checked other resources

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Related Issues / PRs

No response

Reproduction Steps / Example Code (Python)

from langchain_core.structured_query import Visitor, Operator, Comparator

class TestVisitor(Visitor):
    allowed_comparators = (Comparator.EQ,)
    allowed_operators = (Operator.AND,)

    def visit_operation(self, operation):
        pass

    def visit_comparison(self, comparison):
        pass

    def visit_structured_query(self, structured_query):
        pass

v = TestVisitor()
# Trigger the error with an operator that is not in allowed_operators
v._validate_func(Operator.OR)

Error Message and Stack Trace (if applicable)

ValueError: Received disallowed operator Operator.OR. Allowed comparators are (Operator.AND,)

Description

In Visitor._validate_func (langchain_core/structured_query.py), when an
invalid operator is passed, the error message incorrectly says
"Allowed comparators are ..." instead of "Allowed operators are ...".

This is a copy-paste typo. The message should say "operators" to match
what is actually being validated.

The typo is on line 32:

f"Received disallowed operator {func}. Allowed "
f"comparators are {self.allowed_operators}"

System Info

System Information

OS: Darwin
OS Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:55 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T8132
Python Version: 3.12.11 (main, Jul 23 2025, 00:18:05) [Clang 20.1.4 ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing featurecore`langchain-core` package issues & PRsexternal

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions