adk deploy ignores .gitignore patterns that start with **/

Offen
#8,294 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 3 Tagen

@surajksharma07 arbeitet bereits daran.

Seit 23.11.2026.

  • #8296 von @AshfaqueAhbab — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
25/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
gcp, python
Bereich
cli

Rechercherichtung

Start with _get_ignore_patterns_func in cli/cli_deploy.py, which passes the ignore patterns to shutil.ignore_patterns. Leading **/ patterns contain a slash and never match a bare file or folder name, so the stripping logic there needs to handle them. Check the gitignore-style cases listed in the issue, including the trailing slash in **/__pycache__/. Done means copying an agent folder with that function leaves out node_modules and __pycache__ directories. A linked pull request (#8296) is already open, so check it before starting.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

🔴 Required Information

Describe the Bug:
adk deploy reads .gitignore, .gcloudignore and .ae_ignore from the agent folder, but patterns with a leading **/ never match anything. Paths such as **/node_modules or **/__pycache__/ are common in these files, and the matching files and folders are still copied into the deployment.

_get_ignore_patterns_func in cli/cli_deploy.py passes the patterns to shutil.ignore_patterns, which compares them with file and folder names, not paths. **/node_modules contains a /, so it never equals a name. Root-anchored patterns such as /.venv already have their leading / stripped for the same reason.

Steps to Reproduce:

  1. In an agent folder, create node_modules/pkg/index.js, sub/__pycache__/x.pyc and a .gitignore with:
    **/node_modules
    **/__pycache__/
    
  2. Run adk deploy cloud_run (or agent_engine / gke), or copy the folder the way the deploy commands do:
    import shutil
    from google.adk.cli.cli_deploy import _get_ignore_patterns_func
    
    shutil.copytree("agent", "out", ignore=_get_ignore_patterns_func("agent"))
    
  3. Look at what was copied.

Expected Behavior:
node_modules and __pycache__ are left out, as they are by git and gcloud.

Observed Behavior:
Both are copied: out/node_modules/pkg/index.js and out/sub/__pycache__/x.pyc exist.

Environment Details:

  • ADK Library Version: 2.15.0 (main at 2b90353)
  • Desktop OS: Linux
  • Python Version: 3.12.13

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: N/A

🟡 Optional Information

Additional Context:
In .gitignore syntax, a leading **/ means "in any directory", which is what a plain name already matches, so stripping it gives the same result. Patterns with a / in the middle (like docs/build) also never match today, but I'd leave those alone, since approximating them could drop files the agent needs.

How often has this issue occurred?:

  • Always (100%)
Vorherrschende Sprache
Python
Sterne
22.3k
Forks
4.4k
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
6

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus google/adk-python

Alle Issues in google/adk-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.