Skip to content

fix(author): correct LUT prefix nesting in jinja command - #2165

Open
Acuspeedster wants to merge 4 commits into
oscal-compass:developfrom
Acuspeedster:fix/jinja-lut-prefix-nesting
Open

fix(author): correct LUT prefix nesting in jinja command#2165
Acuspeedster wants to merge 4 commits into
oscal-compass:developfrom
Acuspeedster:fix/jinja-lut-prefix-nesting

Conversation

@Acuspeedster

@Acuspeedster Acuspeedster commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Types of changes

  • Hot fix (emergency fix and release)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation (change which affects the documentation site)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Release (develop -> main)

Quality assurance (all should be covered).

  • My code follows the code style of this project.
  • Documentation for my change is up to date?
  • My PR meets testing requirements.
  • All new and existing tests passed.
  • All commits are signed-off.

Summary

Fix trestle author jinja lookup-table prefix wrapping (-elp/--external-lut-prefix) to match documented behavior.

Problem:

  • JinjaCmd.load_LUT() previously mutated the LUT in-place and created self-referential structures when a prefix was provided.
  • This could cause unexpected template variable resolution and did not correctly enforce nested prefix wrapping as documented.

Fix:

  • Read LUT file using a context manager.
  • Build nested prefix wrappers deterministically (e.g., fruit.tropical -> {'fruit': {'tropical': <lut>}}).

Tests:

  • Added regression test for prefix nesting behavior.
  • Updated existing lookup-table test to validate unprefixed LUT behavior without passing -elp.

Files changed:

  • trestle/core/commands/author/jinja.py
  • tests/trestle/core/commands/author/jinja_cmd_test.py

Targeted validation run:

  • pytest tests/trestle/core/commands/author/jinja_cmd_test.py::test_jinja_lookup_table tests/trestle/core/commands/author/jinja_cmd_test.py::test_jinja_lookup_table_prefix_nesting -q --basetemp .pytest_tmp
  • Result: 2 passed

Key links:

Before you merge

  • Ensure it is a 'squash commit' if not a release.
  • Ensure CI is currently passing
  • Check sonar. If you are working for a fork a maintainer will reach out, if required.

Signed-off-by: Acuspeedster <arnavrajsingh@gmail.com>
@Acuspeedster
Acuspeedster requested a review from a team as a code owner March 18, 2026 09:52
Signed-off-by: Acuspeedster <arnavrajsingh@gmail.com>
Signed-off-by: Acuspeedster <arnavrajsingh@gmail.com>
@degenaro

Copy link
Copy Markdown
Collaborator

@butler54 Please review.

@degenaro
degenaro force-pushed the develop branch 2 times, most recently from 64cc98c to 4fa5f11 Compare August 7, 2026 11:15
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.

4 participants