Skip to content

fix(detect): let .env.example-style templates through Stage 2 - #2232

Closed
SyedFahad7 wants to merge 1 commit into
Graphify-Labs:v8from
SyedFahad7:fix/2184-env-template-sensitive
Closed

fix(detect): let .env.example-style templates through Stage 2#2232
SyedFahad7 wants to merge 1 commit into
Graphify-Labs:v8from
SyedFahad7:fix/2184-env-template-sensitive

Conversation

@SyedFahad7

Copy link
Copy Markdown
Contributor

Summary

Fixes #2184.

Stage 2's .env / .envrc regex also matched .env.example (and .sample / .template / .dist), so committed dotenv templates got dumped into skipped_sensitive and never made it into the graph. Real files like .env.local should still be blocked — just not the usual placeholder naming.

Carve-out is suffix + basename only; doesn't reopen a broad Stage 2 allowlist (#1921).

Test plan

  • .env.example / .env.sample are indexed (not in skipped_sensitive)
  • .env, .env.local, .env.production still skipped
  • uv run pytest tests/test_detect.py -q -k sensitive

…ge 2

Stage 2's .env regex treated .env.example / .sample / .template / .dist
like live secret files and dropped them from the graph. Carve out those
suffixes for .env / .envrc basenames only — real .env.local etc. stay blocked.

Fixes Graphify-Labs#2184
Copilot AI review requested due to automatic review settings July 27, 2026 10:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Graphify’s file-sensitivity detection (Stage 2) to stop treating committed dotenv/envrc template files (e.g., .env.example, .env.sample, .env.template, .env.dist) as sensitive, so they can be included in indexing rather than being dropped as secrets.

Changes:

  • Add _ENV_TEMPLATE_SUFFIXES and _is_env_template() to identify committed .env/.envrc template naming patterns.
  • Update _is_sensitive() Stage 2 to exempt these template filenames from _SENSITIVE_PATTERNS matches.
Comments suppressed due to low confidence (1)

graphify/detect.py:278

  • Add tests covering the new behavior: .env.example/.env.sample/.envrc.template should not be reported under skipped_sensitive (and, once classified, should appear in result["files"]["document"]), while .env, .env.local, .env.production remain skipped as sensitive. Current tests assert .env stays excluded but don’t exercise the new template exemption.
    # Stage 2: filename pattern match. Template suffixes (.example/.sample/…)
    # on .env / .envrc are the usual "safe to commit" convention — keep them
    # in the graph without opening a broad Stage 2 allowlist (#2184 / #1921).
    name = path.name
    if any(p.search(name) for p in _SENSITIVE_PATTERNS) and not _is_env_template(name):

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread graphify/detect.py
Comment on lines +274 to +278
# Stage 2: filename pattern match. Template suffixes (.example/.sample/…)
# on .env / .envrc are the usual "safe to commit" convention — keep them
# in the graph without opening a broad Stage 2 allowlist (#2184 / #1921).
name = path.name
if any(p.search(name) for p in _SENSITIVE_PATTERNS):
if any(p.search(name) for p in _SENSITIVE_PATTERNS) and not _is_env_template(name):
safishamsi added a commit that referenced this pull request Jul 28, 2026
….example regression test (#2205, #2184)

Follow-ups on the cherry-picked #2242/#2232: an all-dots label ('...') no
longer produces an empty 'dot-' Obsidian stem (falls back to 'unnamed'),
and the .env.example carve-out gets the regression test it shipped without
(templates graphable, real .env still sensitive, secrets/.env.example still dropped).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@safishamsi

Copy link
Copy Markdown
Collaborator

Thanks @SyedFahad7. Shipped in v0.9.29 (cherry-picked to v8), with the regression test added as a follow-up. Closed-unmerged here, but it's in the release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.29

@safishamsi safishamsi closed this Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

detect(): Stage 2 .env sensitive-pattern regex has no exemption for template suffixes (.env.example, .env.sample, .env.template, .env.dist)

3 participants