mobile: isolate black formatter into mobile-specific pip_parse, update to 26.3.1#44240
Draft
mobile: isolate black formatter into mobile-specific pip_parse, update to 26.3.1#44240
Conversation
Agent-Logs-Url: https://github.com/envoyproxy/envoy/sessions/3afdcd78-362a-4e80-ac9e-daa0750dc356 Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
…ity (CVE) Agent-Logs-Url: https://github.com/envoyproxy/envoy/sessions/3afdcd78-362a-4e80-ac9e-daa0750dc356 Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove black as a direct dependency from shared requirements
mobile: isolate black formatter into mobile-specific pip_parse, update to 26.3.1
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #43605 accidentally added
blacktotools/base/requirements.in— the sharedbase_pip3pip_parse used across the entire repo — even thoughblackis only used by Envoy Mobile for Python formatting. This bloated the shared lockfile withblackand its transitive deps. Additionally,black25.12.0 has a known vulnerability (arbitrary file writes via unsanitized cache file names; patched in 26.3.1).Changes
tools/base/requirements.in— removeblacktools/base/requirements.txt— removeblack==25.12.0and its exclusively-black transitive deps (click,mypy-extensions,pytokens); strip# blackfromviacomments onpathspec,platformdirs, andpackaging(which have other dependents)mobile/tools/requirements.in(new) — single entry:blackmobile/tools/requirements.txt(new) — locked lockfile withblack==26.3.1(patched) and all transitive deps with hashes;pathspecupdated to1.0.4to satisfy black 26.3.1's raised floor of>=1.0.0bazel/python_dependencies.bzl— addmobile_pip3pip_parse pointing at@envoy//mobile/tools:requirements.txtbazel/dependency_imports.bzl— load and callpip_mobile_dependencies()from@mobile_pip3mobile/tools/BUILD— updateblacktarget:@base_pip3//black→@mobile_pip3//blackOriginal prompt
Problem
PR #43605 ("mobile: re-add Python APIs") accidentally added
blackas a direct dependency intools/base/requirements.in— the main/shared Python requirements file used by thebase_pip3pip_parse. This bloats the shared lockfile withblackand all its transitive deps, even thoughblackis only used by Envoy Mobile for formatting Python code inmobile/tools/check_format.sh.Where
blackis usedmobile/tools/BUILD— defines apy_console_script_binarytarget namedblackpulling from@base_pip3//blackmobile/tools/check_format.sh— builds//tools:blackand runs it onlibrary/python,test/python,examples/pythonmobile/pyproject.toml— has[tool.black]configRequired Changes (Option A — mobile-specific pip_parse)
Remove
blackfromtools/base/requirements.in(line 8) — delete theblackline.Regenerate
tools/base/requirements.txt— remove theblackpackage entry and all its hashes from the lockfile, and remove# blackfrom the# viacomments for transitive deps likepathspec,platformdirs,click,mypy-extensions, andpackaging. If any of those transitive deps are ONLY pulled in byblack(i.e., no other package requires them), remove those entries entirely. If they have other dependents, just remove the# blackline from their# viacomments.Create
mobile/tools/requirements.incontaining just:Create
mobile/tools/requirements.txt— a pip-compile lockfile forblackand its transitive dependencies with hashes (--require-hashescompatible). You can extract the relevant entries (black, click, mypy-extensions, pathspec, platformdirs, and their hashes) from the currenttools/base/requirements.txtsince they were just added there.Add a new
pip_parseinbazel/python_dependencies.bzlinside theenvoy_python_dependencies()function:Load and install the new mobile_pip3 deps in
bazel/dependency_imports.bzl:load("@mobile_pip3//:requirements.bzl", pip_mobile_dependencies = "install_deps")pip_mobile_dependencies()in theenvoy_dependency_imports()function alongside the existingpip_dependencies(),pip_dev_dependencies(), etc.Update
mobile/tools/BUILDto reference@mobile_pip3//blackinstead of@base_pip3//black:Important Notes
tools/base/requirements.txtlockfile uses--require-hashes, so the newmobile/tools/requirements.txtmust also include hashes for all packages.tools/base/requirements.txtlistblackin their# viacomments — ifblackis the only dependent, remove those entries entirely from the base lockfile. Key ones to check:click,mypy-extensions,pathspec,platformdirs,packaging(packaging has many other dependents so just remove the# blackvia line).pathspecpackage is also used# via yamllintso it should NOT be removed from base, just have# blackremoved from its via comments.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: recently black was added as a python dep for mobile - it wasnt supposed to be in the main deps - can you look what happened, confirm where its used, and figure out resolution
Assistant:
Let me research this issue by looking at how
blackwas added as a dependency and where it's referenced.Assistant: The commit search is matching on a contributor named "ravenblackx" rather than being useful. Let me look more specifically at where
blackis used and check the git history on the relevant files.Assistant: Now let me check if there's a separate mobile-specific requirements file where
blackshould live instead, and look at git history for whenblackwas added totools/base/requirements.in:Assistant: Here's what I found:
What happened
PR #43605 ("mobile: re-add Python APIs") by @danzh2010, merged on 2026-03-03, added
blackas a direct dependency intools/base/requirements.in(line 8). This is the main/shared Python requirements file used by thebase_pip3pip_parse — it feeds all Bazel Python tooling across the entire repository, not just mobile.Where
blackis actually usedblackis only used by Envoy Mobile for formatting Python code:mobile/tools/BUILD— defines apy_console_script_binarytarget namedblackthat pulls from@base_pip3//blackmobile/tools/check_format.sh— builds `//tools:black...This pull request was created from Copilot chat.