Skip to content

docs: Clarify Files.Lines behavior for empty and missing files#2174

Draft
promptless-for-oss wants to merge 2 commits into
helm:mainfrom
Promptless:promptless/files-lines-empty-file-behavior
Draft

docs: Clarify Files.Lines behavior for empty and missing files#2174
promptless-for-oss wants to merge 2 commits into
helm:mainfrom
Promptless:promptless/files-lines-empty-file-behavior

Conversation

@promptless-for-oss

Copy link
Copy Markdown
Contributor

Open this suggestion in Promptless to view citations and reasoning process

Documents that .Files.Lines returns an empty list (not an error) when the referenced file is empty or missing, in the Chart Template Guide "Accessing Files Inside Templates" page. Applied to both the current (v4) and v3 docs. Grounded in helm/helm PR #32303, which fixes an index-out-of-range panic on empty files so they behave like missing files.

Trigger Events


Tip: Use labels in the Promptless dashboard to categorize suggestions by release or team 🏷️

Signed-off-by: promptless[bot] <promptless[bot]@users.noreply.github.com>
{{ . }}{{ end }}
```

If the file you reference is empty or does not exist, `Lines` returns an empty

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added the empty/missing-file note because this PR changes files.Lines in pkg/engine/files.go — the guard becomes len(f[path]) == 0 so empty files return an empty []string{} like missing files already did, instead of panicking with index-out-of-range and failing the render.

Source: helm/helm#32303

{{ . }}{{ end }}
```

If the file you reference is empty or does not exist, `Lines` returns an empty

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Applied the same Lines note to the current (v4) docs because PR #32303 is the v3 backport of #32290, which lands the identical pkg/engine/files.go fix on main, so the empty-file behavior holds for v4 as well.

Source: helm/helm#32290

…s-empty-file-behavior

# Conflicts:
#	docs/chart_template_guide/accessing_files.md
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.

1 participant