Skip to content

.thvignore directory patterns with wildcards never match #7182

Done

Description

@mansur-akhmadi

Bug description

A .thvignore directory pattern (one ending in /) that contains a wildcard never matches anything, so the directories it is meant to hide stay visible in the container. The same pattern without the trailing slash works.

getMatchingPaths in pkg/ignore/processor.go only checks a directory pattern as a literal path (os.Stat) and returns early; the filepath.Glob fallback is reached only by patterns without a trailing slash.

Steps to reproduce

  1. In a directory to be mounted, create secrets-prod/ and secrets-dev/.
  2. Add secrets-*/ to its .thvignore (or to ~/.config/toolhive/thvignore).
  3. thv run <server> -v <dir>:/workspace.

Expected behavior

/workspace/secrets-prod and /workspace/secrets-dev are overlaid with empty directories, as they are for secrets-* or secrets-prod/.

Actual behavior

No overlay is created for them; GetOverlayMounts returns nothing for the pattern, and the directories' contents are visible in the container. Common .gitignore-style entries such as *.egg-info/ are affected the same way.

Environment (if relevant)

  • OS/version: any (logic bug in pkg/ignore)
  • ToolHive version: main @ e8597e2

Additional context

I have a fix ready and will open a PR: directory patterns go through the same literal-then-glob lookup as other patterns, and the glob results are filtered to directories. Fuller gitignore semantics (matching at any depth, **, !) are out of scope for it.

Activity

  1. added
    needs-triage
    on Nov 18, 2026
  2. HankGrimm commented on Nov 24, 2026

    @HankGrimm
    Contributor

    I'd like to work on this. The bug is in getMatchingPaths (pkg/ignore/processor.go): a directory pattern ending in / is only checked as a literal path (os.Stat) and returns early, so the filepath.Glob fallback is never reached for wildcard patterns like secrets-*/ or *.egg-info/. The fix is to fall through to glob (with the trailing slash trimmed) when the literal directory doesn't exist, plus a regression test. Could you assign the issue to me?

  3. mansur-akhmadi commented on Nov 24, 2026

    @mansur-akhmadi
    Author

    There's already a PR for this: #7183. It globs a pattern ending in / with the slash trimmed and keeps only the directories it matches, so secrets-*/ and *.egg-info/ work, and it adds regression tests. It's waiting for review.

  4. removed
    needs-triage
    on Nov 24, 2026
  5. added a commit that references this issue on Nov 25, 2026
    1041630
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions