Skip to content

Fix: files with _snippets in their name incorrectly treated as snippet-only files#2743

Merged
cotti merged 3 commits into
mainfrom
copilot/fix-build-failure-snippets
Jun 5, 2026
Merged

Fix: files with _snippets in their name incorrectly treated as snippet-only files#2743
cotti merged 3 commits into
mainfrom
copilot/fix-build-failure-snippets

Conversation

Copilot AI commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Substring matching on "_snippets" caused files like top_snippets.md to be classified as SnippetFile (excluded from normal processing) instead of regular MarkdownFile.

Changes

  • MarkdownFileFactory.cs: Replace relativePath.Contains("_snippets") with path-component-aware check — requires _snippets to be a directory segment, not a substring of a filename
  • IncludeBlock.cs: Same fix for include validation — splits on path separators and checks for exact component match instead of IndexOf("_snippets")
  • MockFileSystemExtensions.cs: Fix test helper's Contains("_snippet") (note: missing trailing s) which had the same over-matching behavior when generating docset YAML TOC entries
// Before — matches top_snippets.md, path/to/top_snippets/file.md, etc.
if (relativePath.Contains("_snippets"))

// After — only matches when _snippets is an actual directory component
if (relativePath.Contains($"{Path.DirectorySeparatorChar}_snippets{Path.DirectorySeparatorChar}")
    || relativePath.StartsWith($"_snippets{Path.DirectorySeparatorChar}"))
Original prompt

This section details on the original issue you should resolve

<issue_title>Build fails when filename contains _snippets</issue_title>
<issue_description>Files with _snippets in the filename (e.g. top_snippets.md) cause build failures, presumably because the build logic treats any path containing _snippets as an include-only snippets directory.

Expected behavior

Only _snippets/ directories should be treated specially, not files that happen to contain _snippets in their name.

Workaround

Rename files to kebab case (e.g. top-snippets.md).

Reference

<agent_instructions>I think the easiest would be to detect the snippets folder using /_snippets </agent_instructions>

Comments on the Issue (you are @copilot in this section)

@reakaleek I guess the easiest would be to change the detection to `/_snippets`

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ining _snippets

Co-authored-by: reakaleek <16325797+reakaleek@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build failure caused by filenames containing _snippets Fix: files with _snippets in their name incorrectly treated as snippet-only files Feb 19, 2026
Copilot AI requested a review from reakaleek February 19, 2026 13:07
@reakaleek reakaleek added the fix label Feb 19, 2026
@reakaleek reakaleek marked this pull request as ready for review February 19, 2026 13:09
@reakaleek reakaleek requested a review from a team as a code owner February 19, 2026 13:09
…lure-snippets

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	src/Elastic.Markdown/Myst/Directives/Include/IncludeBlock.cs
@cotti cotti had a problem deploying to integration-tests June 4, 2026 23:22 — with GitHub Actions Failure
@cotti cotti temporarily deployed to integration-tests June 4, 2026 23:48 — with GitHub Actions Inactive
@cotti cotti merged commit d115285 into main Jun 5, 2026
33 of 34 checks passed
@cotti cotti deleted the copilot/fix-build-failure-snippets branch June 5, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build fails when filename contains _snippets

4 participants