## Problem The `draw_mermaid_png()` function fails with HTTP 400 when using named background colors like `white`. This is because named colors get prefixed with `!` (e.g., `!white`) but this special character is not URL-encoded before being added to the API URL. As reported in #34444, the URL parameter `bgColor=!white` causes mermaid.ink to return a 400 Bad Request error. ## Solution URL-encode the `background_color` parameter using `urllib.parse.quote()` before constructing the API URL. This ensures special characters like `!` are properly encoded as `%21`. ## Changes - Added `import urllib.parse` - URL-encode `background_color` value with `urllib.parse.quote(str(background_color), safe="")` - Added 2 unit tests: - `test_mermaid_bgcolor_url_encoding`: Verifies named colors are properly encoded - `test_mermaid_bgcolor_hex_not_encoded`: Verifies hex colors work correctly ## Testing ```bash pytest tests/unit_tests/runnables/test_graph.py::test_mermaid_bgcolor_url_encoding -v pytest tests/unit_tests/runnables/test_graph.py::test_mermaid_bgcolor_hex_not_encoded -v ``` Both tests pass. Fixes #34444 --- *This contribution was made with AI assistance (Claude).* Co-authored-by: Mr-Neutr0n <mrneutron@users.noreply.github.com> Co-authored-by: Mason Daugherty <mason@langchain.dev>
Packages
Important
This repository is structured as a monorepo, with various packages located in this libs/ directory. Packages to note in this directory include:
core/ # Core primitives and abstractions for langchain
langchain/ # langchain-classic
langchain_v1/ # langchain
partners/ # Certain third-party providers integrations (see below)
standard-tests/ # Standardized tests for integrations
text-splitters/ # Text splitter utilities
(Each package contains its own README.md file with specific details about that package.)
Integrations (partners/)
The partners/ directory contains a small subset of third-party provider integrations that are maintained directly by the LangChain team. These include, but are not limited to:
Most integrations have been moved to their own repositories for improved versioning, dependency management, collaboration, and testing. This includes packages from popular providers such as Google and AWS. Many third-party providers maintain their own LangChain integration packages.
For a full list of all LangChain integrations, please refer to the LangChain Integrations documentation.