You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: autodiscovery crashes with mixed resource types (#637)
* fix: autodiscovery now uses glob patterns instead of explicit paths
Fixes autodiscovery crash when projects contain both HelmChart manifests
and Support Bundle specs (or other mixed resource types).
## Problem
Autodiscovery was storing explicit file paths in the config instead of
glob patterns. This caused the extraction phase to use strict validation
(explicit path mode) instead of lenient filtering (glob pattern mode).
When mixed resource types existed (e.g., HelmChart + Support Bundle), the
strict validation would fail:
- DiscoverSupportBundlesFromManifests() processes all paths in config.Manifests
- It tries to validate helmchart.yaml as a SupportBundle
- Error: "file does not contain kind: SupportBundle"
## Root Cause
The extraction layer (`extractAllPathsAndMetadata`) was designed for glob
patterns, not explicit paths. Non-autodiscovery configs use patterns like
"./**/*.yaml" which trigger lenient filtering. Autodiscovery was storing
explicit paths like "./manifests/helmchart.yaml" which trigger strict
validation.
## Solution
Make autodiscovery store glob patterns (`./**`) instead of explicit file
paths. This:
- ✅ Eliminates code path duplication (both use same extraction logic)
- ✅ Fixes the bug (glob patterns use lenient filtering)
- ✅ Maintains discovery counts for user display
- ✅ Follows the design pattern of the system
Discovery still happens twice (once for counting/display, once for
extraction), but this is conceptually correct and has negligible
performance impact.
## Changes
- Autodiscovery block now stores patterns, not paths
- Added comprehensive test with all resource types (Chart, Preflight,
Support Bundle, HelmChart manifest)
- Test reproduces the bug before the fix, passes after
## Testing
- Added TestLint_AutodiscoveryWithMixedManifests
- All existing lint tests still pass
- All pkg/lint2 tests still pass
* test: add comprehensive autodiscovery test coverage
Adds 5 additional tests to thoroughly cover autodiscovery scenarios.
## Phase 1: Critical Edge Cases
- TestLint_AutodiscoveryEmptyProject: Validates graceful handling of empty directories
- TestLint_AutodiscoveryChartWithoutHelmChart: Validates error when chart lacks HelmChart manifest
- TestLint_AutodiscoveryMultipleCharts: Tests scaling with multiple charts
## Phase 2: Robustness
- TestLint_AutodiscoveryHiddenDirectories: Confirms .git, .github, etc. are ignored
- TestLint_AutodiscoveryBothYamlExtensions: Tests both .yaml and .yml file discovery
All tests pass, bringing total autodiscovery test coverage to 6 tests:
1. Mixed manifests (bug reproduction + fix validation)
2. Empty project
3. Chart without HelmChart
4. Multiple charts
5. Hidden directories
6. Both YAML extensions
This provides comprehensive coverage of autodiscovery functionality.
* refactor: clean up redundant comments in autodiscovery code
Remove redundant 'Use recursive wildcard pattern' comments since the
parent comment (lines 177-178) already explains the glob pattern approach.
Add more meaningful comment explaining why Support Bundles and HelmChart
manifests are combined into config.Manifests.
0 commit comments