Skip to content

fix(agent-discovery): match nested config files on Windows - #4325

Open
Anish Mehta (anishmehta24) wants to merge 2 commits into
microsoft:mainfrom
anishmehta24:fix/discovery-config-scanner-windows-paths
Open

Anish Mehta (anishmehta24) wants to merge 2 commits into
microsoft:mainfrom
anishmehta24:fix/discovery-config-scanner-windows-paths

Conversation

@anishmehta24

Copy link
Copy Markdown

Related Issue

None. Problem & Solution, Impact and Alternatives are filled in below.

Problem & Solution

Problem: ConfigScanner builds the relative path with str(rel_dir / filename) and compares it with patterns like .agentmesh/config.yaml and .mcp/config.json. On Windows that path uses backslashes, so those two patterns never match and the configs are not reported. Only the bare-filename patterns work there.

Solution: build the path with as_posix(), so the patterns and the config_file tag use / on every platform.

Impact on Your Work

Running agent-discovery scan -s config on Windows over a project with .agentmesh/config.yaml and .mcp/config.json found only crewai.yaml.

Timeline

None

Alternatives Considered

Normalizing the patterns to os.sep instead. as_posix() is simpler and keeps the tag the same across platforms.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Maintenance (dependency updates, CI/CD, refactoring)
  • Security fix

Package(s) Affected

Governance & security:

  • agent-discovery

Testing

Unit Testing

Added TestConfigScanner.test_finds_config_files_in_subdirectories (there were no ConfigScanner tests). It fails on Windows before the change and passes after. On Linux it passes either way, so it only guards Windows (#3896 adds a Windows CI job). The agent-discovery suite passes (58 tests).

Manual Testing

Ran the scanner on Windows over a folder with .agentmesh/config.yaml, .mcp/config.json and crewai.yaml. Before: only crewai.yaml. After: all three.

Checklist

  • I have linked a related issue above, or completed "Problem & Solution", "Impact on Your Work", and "Alternatives Considered"
  • My code follows the project style guidelines (ruff check)
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass (pytest)
  • I have updated documentation as needed
  • I have signed the Microsoft CLA

Attribution & Prior Art

  • This contribution does not contain code copied or derived from other projects without attribution
  • Any external projects that inspired this design are credited in code comments or documentation
  • If this PR implements functionality similar to an existing open-source project, I have listed it below

Prior art / related projects (if any):

AI Assistance

  • I can explain every meaningful change in this PR: what it does, why, and what tradeoffs were considered
  • I have run tests and verification appropriate for this change
  • No part of this PR was autonomously submitted by an AI agent without my review
  • I have not used AI to generate review comments on others' PRs

If AI tools materially shaped this change, briefly note what was used:
Claude Code helped find the bug and draft the fix and test. I reviewed the change and ran the tests.

IP, Patents, and Licensing

  • This contribution does not implement patent-pending or patent-encumbered techniques
  • This contribution does not require an NDA or licensing agreement to understand or use
  • Any AI tools used have terms compatible with the MIT License

ConfigScanner built the relative path with str(), which uses
backslashes on Windows, so the .agentmesh/config.yaml and
.mcp/config.json patterns never matched there. Use as_posix() so the
patterns match on every platform.

Signed-off-by: Anish Mehta <mehtaanish111@gmail.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions github-actions Bot added tests size/S Small PR (< 50 lines) labels Oct 15, 2026
@github-actions

Copy link
Copy Markdown

PR Review Summary

Check Status Details
🔍 Code Review ⚠️ Missing No current-run comment
🛡️ Security Scan ⚠️ Missing No current-run comment
🔄 Breaking Changes ⚠️ Missing No current-run comment
📝 Docs Sync ⚠️ Missing No current-run comment
🧪 Test Coverage ⚠️ Missing No current-run comment

Verdict: ⚠️ AI review incomplete; ready for human review

AI review comments are untrusted advisory output. The summary reports workflow-generated completion status only, not model-authored pass/fail claims.

@github-actions

Copy link
Copy Markdown

🔴 Contributor Check: HIGH

Check Result
Profile HIGH
Credential LOW
Overall HIGH

Automated check by AGT Contributor Check.

@github-actions github-actions Bot added the needs-review:HIGH Contributor reputation check flagged HIGH risk label Oct 15, 2026

@MohammadHaroonAbuomar MohammadHaroonAbuomar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • Verified by simulation with PureWindowsPath: str(rel_dir / filename) yields .agentmesh\config.yaml, which never matches the .agentmesh/config.yaml patterns, and .as_posix() does; stored fingerprints are unchanged because they use the full path. 58 tests pass, lint and spelling clean, template complete. One sibling to bring along.
  • agent-governance-python/agent-discovery/src/agent_discovery/scanners/config.py:208 The docker_file tag still uses str(rel_dir / filename), so on Windows it keeps backslashes while config_file is now POSIX. Please switch it to .as_posix() too so the two tags stay consistent.

Signed-off-by: Anish Mehta <mehtaanish111@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review:HIGH Contributor reputation check flagged HIGH risk size/S Small PR (< 50 lines) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants