helm/helm · error
not a directory
Error message
not a directory
What it means
setIndex (pkg/strvals/parser.go:308) rejects negative indexes with this message. For normal --set input this guard is shadowed by the earlier check in parser.listItem (parser.go:335), so seeing it means setIndex was reached with i < 0 directly — typically the same malformed input ('a[-1]=v') but observed from the lower-level call path, or a program calling setIndex-shaped flows via the public Parse APIs on unusual input.
Source
Thrown at internal/chart/v3/lint/rules/template.go:218
return scanner.Err()
}
// Validation functions
func templatesDirExists(templatesPath string) error {
_, err := os.Stat(templatesPath)
if errors.Is(err, os.ErrNotExist) {
return errors.New("directory does not exist")
}
return nil
}
func validateTemplatesDir(templatesPath string) error {
fi, err := os.Stat(templatesPath)
if err != nil {
return err
}
if !fi.IsDir() {
return errors.New("not a directory")
}
return nil
}
func validateAllowedExtension(fileName string) error {
ext := filepath.Ext(fileName)
validExtensions := []string{".yaml", ".yml", ".tpl", ".txt"}
if slices.Contains(validExtensions, ext) {
return nil
}
return fmt.Errorf("file extension '%s' not valid. Valid extensions are .yaml, .yml, .tpl, or .txt", ext)
}
func validateYamlContent(err error) error {
if err != nil {
return fmt.Errorf("unable to parse YAML: %w", err)View on GitHub (pinned to 2a29f1770b)
Solutions
- Use a non-negative 0-based index
- Compute the correct index client-side instead of relying on negative semantics
- Validate bracket contents are ^\[\d+\]$ before calling Parse
Example fix
// before
strvals.Parse("items[-1]=x")
// after
strvals.Parse("items[0]=x") Defensive patterns
Strategy: validation
Validate before calling
var negIdx = regexp.MustCompile(`\[-\d+\]`)
func hasNegativeIndex(setLine string) bool { return negIdx.MatchString(setLine) } Try / catch
if err := strvals.Parse(s); err != nil {
if strings.Contains(err.Error(), "negative") && strings.Contains(err.Error(), "index not allowed") { /* fix index */ }
} Prevention
- Clamp computed indexes to >= 0
- Compute last-element position from known length
- Lint expressions for negative brackets
When it happens
Trigger: strvals.Parse("a[-1]=v") normally surfaces the listItem variant; this variant appears when the negative index reaches setIndex itself, e.g. through nested paths or direct library use patterns.
Common situations: Same as negative-index errors generally: negative indexing expectations, bad interpolation producing -1, off-by-one loop counters.
Related errors
- file does not exist
- each maintainer requires a name
- icon is recommended
- not a directory
- apiVersion is not in 'apiextensions.k8s.io'
AI-assisted analysis of helm/helm@2a29f1770b (2026-08-15).
Data as JSON: /api/errors/25157056f8e73925.
Report an issue: GitHub.