Skip to content

TemplateNotFound for Jinja2 when --jinja is a filename outside ./templates #31

@robertsonc

Description

@robertsonc

Summary

preconfig.py hardcodes FileSystemLoader("templates"), so --jinja ec_preconfig_template.jinja2
fails unless the file is inside ./templates. This causes jinja2.exceptions.TemplateNotFound.

Expected behavior

--jinja should accept:

  • an absolute path
  • a relative path
  • just a filename found in either . or ./templates

Actual behavior

Raises jinja2.exceptions.TemplateNotFound: ec_preconfig_template.jinja2 unless the file
exists in ./templates.

Steps to reproduce

  1. Place ec_preconfig_template.jinja2 in the repo root (not in ./templates)

  2. Run: python3 preconfig.py -c my-preconfig.csv --jinja ec_preconfig_template.jinja2 -o <orch_url>

  3. Observe TemplateNotFound.

Proposed fix

Allow --jinja to be a path and search in ['<arg parent>', '.', 'templates']. Provide a clear
error message listing the directories searched.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions