Skip to content

When rendering JSONT, an undefined env var results in a syntax error #184

@jabortell

Description

@jabortell

Our starter bundle doesn't seem to be able to run without syntax errors. In the _template_bundle folder, the studentAssessments.jsont has two Jinja if-statements on ${EDFI_DS_VERSION} to determine whether to include performanceLevels[].performanceLevelMet. Here's one:

  "performanceLevels": [
    {% for perf_level in perf_levels %}
      {
        "assessmentReportingMethodDescriptor": "{{namespace}}/AssessmentReportingMethodDescriptor#{{perf_level[1]}}",
        "performanceLevelDescriptor": "{{namespace}}/PerformanceLevelDescriptor#{{perf_level[0]}}"
        {%- if ${EDFI_DS_VERSION}|int < 4 -%}
        ,"performanceLevelMet": true
        {% endif %}
      } {% if not loop.last %},{% endif %}
    {% endfor %}
  ],

However, earthmover.yaml does not include EDFI_DS_VERSION in the config.parameter_defaults section.

config:
  log_level: INFO
  output_dir: ${OUTPUT_DIR}
  memory_limit: 1GB
  state_file: ${STATE_FILE}
  show_graph: False
  show_stacktrace: true
  parameter_defaults:
    STUDENT_ID_NAME: 'edFi_studentUniqueID' # default to the column added by the apply_xwalk package of student ID xwalking feature
    POSSIBLE_STUDENT_ID_COLUMNS: studentId
    DESCRIPTOR_NAMESPACE: uri://ed-fi.org

The result is a syntax error:

2026-01-20 07:58:14.954 earthmover ERROR (near line 134 of `/home/jbortell/git/edanalytics/earthmover_edfi_bundles/assessments/Missouri_Assessment_Program/earthmover.yaml` in `$destinations.studentAssessments`)  syntax error in Jinja template in `template` file ./templates/studentAssessments.jsont (unexpected char '$' at 2082))
Traceback (most recent call last):
  File "/home/jbortell/.local/share/uv/tools/earthmover/lib/python3.10/site-packages/earthmover/nodes/destination.py", line 98, in execute
    self.jinja_template = util.build_jinja_template(template_string, macros=self.earthmover.macros, base_dir=self.config_dir)
  File "/home/jbortell/.local/share/uv/tools/earthmover/lib/python3.10/site-packages/earthmover/util.py", line 132, in build_jinja_template
    ).from_string(macros.strip() + template_string)
  File "/home/jbortell/.local/share/uv/tools/earthmover/lib/python3.10/site-packages/jinja2/environment.py", line 1111, in from_string
    return cls.from_code(self, self.compile(source), gs, None)
  File "/home/jbortell/.local/share/uv/tools/earthmover/lib/python3.10/site-packages/jinja2/environment.py", line 771, in compile
    self.handle_exception(source=source_hint)
  File "/home/jbortell/.local/share/uv/tools/earthmover/lib/python3.10/site-packages/jinja2/environment.py", line 942, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<unknown>", line 1, in template
jinja2.exceptions.TemplateSyntaxError: unexpected char '$' at 2082

If I define EDFI_DS_VERSION with a parameter default, then there is no syntax error.

We should either include this variable in the config or remove it from studentAssessments.jsont. Ideally, we should also capture the error and report the specific problem to the user.

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