Skip to content

fix(template-linter): filter out temporary files from lint results#1377

Closed
hazdl wants to merge 2 commits into
mainfrom
hz/file-handling-in-template-linter
Closed

fix(template-linter): filter out temporary files from lint results#1377
hazdl wants to merge 2 commits into
mainfrom
hz/file-handling-in-template-linter

Conversation

@hazdl

@hazdl hazdl commented Jun 8, 2026

Copy link
Copy Markdown
  • Temporary files generated during linting were previously included in results, causing noise in CI and local lint outputs. This ensures only meaningful files are considered.
  • Verified CI passes successfully after the change
  • passed all CI checks including formatting, clippy, and build tests

@hazdl hazdl assigned JamesDoingStuff and unassigned hazdl Jun 8, 2026
let mut results = lint_from_manifest(&path_buf, true)?;

// Filter out tmp files
results.retain(|r| !r.name.starts_with("/tmp/argo-lint"));

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.

Thanks for working on this. Maybe I don't understand but what problem does this actually solve?

This is the current implementation:

pub fn lint_from_helm(target: &Path, all: bool) -> Result<Vec<LintResult>, String> {
    // FIXME: does not respect $TMPDIR and potential race condition / permissions issue on multi-user systems
    let tmp_dir = Path::new("/tmp/argo-lint");
    let manifests = helm_to_manifest(target, all)?;
    write_to_clean_folder(tmp_dir, manifests)
        .map_err(|_e| "Couldn't create temporary file for helm templates.")?;

    let path_buf = tmp_dir.to_path_buf();
    lint_from_manifest(&path_buf, true)
}

As far as I can tell this:

(1) Runs helm on helm templates to produce manifests.
(2) Writes manifests to /tmp/argo-lint
(3) Runs argo linter on the files in /tmp/argo-lint.

If you then do:

results.retain(|r| !r.name.starts_with("/tmp/argo-lint"));

you remove all results from files in /tmp/argo-lint which was all of the manifests?

The effect of this PR is that that lint_from_helm lints nothing?

I'm not sure what the intention is behind this PR?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I might have confused things when I created the ticket for this without having looked through the CLI code. I read /tmp and assumed it was linting something that wasn't meant to be included - I didn't realise that that was how helm-based workflows are handled.
Rather than filtering the tmp workflows out, I think the purpose of this ticket should instead be to make sure that the name of the helm workflow gets passed to the report - Template Name: /tmp/argo-lint/workflow_2.yaml - Errors found isn't very helpful

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

As I understand it, the linting process checks the temporary folder before any files are generated, which results in a linting error because the folder is empty. Since the folder is populated at runtime, I excluded it from the linting checks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If it does fail with some kind of 'failed to find any workflows' error then I think that would be a separate issue. Contrary to what I wrote in the ticket, we do want these tmp files to be linted - they correspond to the helm-based workflow templates. These workflows can't be linted with the standard Argo Workflow linter because of the helm templating, so they must be parsed using helm template first - this creates the tmp files at runtime, and these can be linted normally

@davehadley

davehadley commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

It's a good idea to include a scope in your conventional commit messages (eg "fix(cli): I fixed the CLI").
You can see the repo git commit history for examples. This helps parse what parts of the codebase were changed by a commit at a glance and maintains consistency with other commits.

see: https://www.conventionalcommits.org/en/v1.0.0/

@davehadley

Copy link
Copy Markdown
Collaborator

After discussion we decided to close this PR for now.

@davehadley davehadley closed this Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants