Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidationError while using RequestsGetTool(allow_dangerous_requests=True) #30498

Open
5 tasks done
GivenFLY opened this issue Mar 26, 2025 · 4 comments
Open
5 tasks done
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature investigate Flagged for investigation.

Comments

@GivenFLY
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • 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).

Example Code

The example code:

from langchain_community.tools import RequestsGetTool

requests_tool = RequestsGetTool(allow_dangerous_requests=True)

Error Message and Stack Trace (if applicable)

---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
Cell In[2], line 3
      1 from langchain_community.tools import RequestsGetTool
----> 3 requests_tool = RequestsGetTool(allow_dangerous_requests=True)

File ~\AppData\Local\pypoetry\Cache\virtualenvs\deep-research-poc-JwCdMXLA-py3.12\Lib\site-packages\langchain_community\tools\requests\tool.py:47, in BaseRequestsTool.__init__(self, **kwargs)
     36 if not kwargs.get("allow_dangerous_requests", False):
     37     raise ValueError(
     38         "You must set allow_dangerous_requests to True to use this tool. "
     39         "Requests can be dangerous and can lead to security vulnerabilities. "
   (...)     45         "further security information."
     46     )
---> 47 super().__init__(**kwargs)

File ~\AppData\Local\pypoetry\Cache\virtualenvs\deep-research-poc-JwCdMXLA-py3.12\Lib\site-packages\langchain_core\tools\base.py:440, in BaseTool.__init__(self, **kwargs)
    435     msg = (
    436         "args_schema must be a subclass of pydantic BaseModel or "
    437         f"a JSON schema dict. Got: {kwargs['args_schema']}."
    438     )
    439     raise TypeError(msg)
--> 440 super().__init__(**kwargs)

File ~\AppData\Local\pypoetry\Cache\virtualenvs\deep-research-poc-JwCdMXLA-py3.12\Lib\site-packages\langchain_core\load\serializable.py:125, in Serializable.__init__(self, *args, **kwargs)
    123 def __init__(self, *args: Any, **kwargs: Any) -> None:
    124     """"""
--> 125     super().__init__(*args, **kwargs)

File ~\AppData\Local\pypoetry\Cache\virtualenvs\deep-research-poc-JwCdMXLA-py3.12\Lib\site-packages\pydantic\main.py:214, in BaseModel.__init__(self, **data)
    212 # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    213 __tracebackhide__ = True
--> 214 validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    215 if self is not validated_self:
    216     warnings.warn(
    217         'A custom validator is returning a value other than `self`.\n'
    218         "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
    219         'See the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details.',
    220         stacklevel=2,
    221     )

ValidationError: 1 validation error for RequestsGetTool
requests_wrapper
  Field required [type=missing, input_value={'allow_dangerous_requests': True}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.10/v/missing

Description

I have provided an expampe code and an error, I think there is no need for more context

System Info

System Information
------------------
> OS:  Windows
> OS Version:  10.0.26100
> Python Version:  3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)]

Package Information
-------------------
> langchain_core: 0.3.48
> langchain: 0.3.21
> langchain_community: 0.3.20
> langsmith: 0.3.18
> langchain_anthropic: 0.3.10
> langchain_openai: 0.3.10
> langchain_text_splitters: 0.3.7
> langgraph_sdk: 0.1.59

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> aiohttp<4.0.0,>=3.8.3: Installed. No version info available.
> anthropic<1,>=0.49.0: Installed. No version info available.
> async-timeout<5.0.0,>=4.0.0;: Installed. No version info available.
> dataclasses-json<0.7,>=0.5.7: Installed. No version info available.
> httpx: 0.28.1
> httpx-sse<1.0.0,>=0.4.0: Installed. No version info available.
> jsonpatch<2.0,>=1.33: Installed. No version info available.
> langchain-anthropic;: Installed. No version info available.
> langchain-aws;: Installed. No version info available.
> langchain-azure-ai;: Installed. No version info available.
> langchain-cohere;: Installed. No version info available.
> langchain-community;: Installed. No version info available.
> langchain-core<1.0.0,>=0.3.45: Installed. No version info available.
> langchain-core<1.0.0,>=0.3.48: Installed. No version info available.
> langchain-deepseek;: Installed. No version info available.
> langchain-fireworks;: Installed. No version info available.
> langchain-google-genai;: Installed. No version info available.
> langchain-google-vertexai;: Installed. No version info available.
> langchain-groq;: Installed. No version info available.
> langchain-huggingface;: Installed. No version info available.
> langchain-mistralai;: Installed. No version info available.
> langchain-ollama;: Installed. No version info available.
> langchain-openai;: Installed. No version info available.
> langchain-text-splitters<1.0.0,>=0.3.7: Installed. No version info available.
> langchain-together;: Installed. No version info available.
> langchain-xai;: Installed. No version info available.
> langchain<1.0.0,>=0.3.21: Installed. No version info available.
> langsmith-pyo3: Installed. No version info available.
> langsmith<0.4,>=0.1.125: Installed. No version info available.
> langsmith<0.4,>=0.1.17: Installed. No version info available.
> numpy<3,>=1.26.2: Installed. No version info available.
> openai-agents: Installed. No version info available.
> openai<2.0.0,>=1.68.2: Installed. No version info available.
> opentelemetry-api: Installed. No version info available.
> opentelemetry-exporter-otlp-proto-http: Installed. No version info available.
> opentelemetry-sdk: Installed. No version info available.
> orjson: 3.10.16
> packaging: 24.2
> packaging<25,>=23.2: Installed. No version info available.
> pydantic: 2.10.6
> pydantic-settings<3.0.0,>=2.4.0: Installed. No version info available.
> pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
> pydantic<3.0.0,>=2.7.4: Installed. No version info available.
> pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
> pytest: Installed. No version info available.
> PyYAML>=5.3: Installed. No version info available.
> requests: 2.32.3
> requests-toolbelt: 1.0.0
> requests<3,>=2: Installed. No version info available.
> rich: Installed. No version info available.
> SQLAlchemy<3,>=1.4: Installed. No version info available.
> tenacity!=8.4.0,<10,>=8.1.0: Installed. No version info available.
> tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
> tiktoken<1,>=0.7: Installed. No version info available.
> typing-extensions>=4.7: Installed. No version info available.
> zstandard: 0.23.0
@langcarl langcarl bot added the investigate Flagged for investigation. label Mar 26, 2025
@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Mar 26, 2025
@ccurme
Copy link
Collaborator

ccurme commented Mar 26, 2025

All requests tools include requests_wrapper as a required parameter: https://python.langchain.com/api_reference/community/tools/langchain_community.tools.requests.tool.BaseRequestsTool.html

Docs here demonstrate how to initialize it and pass it in.

Are there docs that demonstrate initialization without this parameter?

@GivenFLY
Copy link
Author

Oh, I get it now — I didn’t realize requests_wrapper is required. I’m used to seeing required arguments listed at the top of the docs, and here it’s further down the page:

https://python.langchain.com/api_reference/community/tools/langchain_community.tools.requests.tool.RequestsGetTool.html#langchain_community.tools.requests.tool.RequestsGetTool.requests_wrapper

Thanks for the help! Maybe it would be useful to mention that at the top or show a clearer error if requests_wrapper is missing?

@eyurtsev
Copy link
Collaborator

We can't do much about the error message -- it's the pydantic default unfortunately

@GivenFLY
Copy link
Author

Btw, if anyone runs into the same error in the future, here’s a quick way to make it work:

from langchain_community.utilities import TextRequestsWrapper  # or JsonRequestsWrapper or any other wrapper you need
from langchain_community.tools import RequestsGetTool

wrapper = TextRequestsWrapper()
requests_tool = RequestsGetTool(
    requests_wrapper=wrapper,
    allow_dangerous_requests=True
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature investigate Flagged for investigation.
Projects
None yet
Development

No branches or pull requests

3 participants