Skip to content

[BUG] indentparameters incompatible with standard Jinja2 #379

@yu-iskw

Description

@yu-iskw

Describe the bug
The indent filter in dbt-fusion uses different parameter names than the standard Jinja2 implementation, causing macros that follow Jinja2 conventions to fail with "Too many positional arguments" errors. This breaks compatibility with standard Jinja2 templates and documentation.

What version of dbt Fusion is this bug in? (find out by running dbt --version)
Current version (based on codebase analysis)

Is this a discrepancy between the dbt Fusion Engine and dbt Core? Check one.

  • YES
  • NO

To Reproduce

Open this workspace and follow the instructions in README, or do the steps below:

  1. Create a macro file macros/test_indent_compatibility.sql:
{% macro test_indent_compatibility() %}
  {# This should work according to Jinja2 documentation but fails in dbt-fusion #}
  {% set sample_text = "Sample description" | indent(width=6, first=False) %}
  {{ sample_text }}
{% endmacro %}
  1. Run the macro:
dbt run-operation test_indent_compatibility
  1. Observe the error:
error: dbt1501: Failed to run operation too many arguments: Too many positional arguments
(in macros/test_indent_compatibility.sql:2)
  --> macros/test_indent_compatibility.sql:2:37

The issue has been written and saved to issue.md. This comprehensive issue:

  1. Clearly describes the bug - Parameter incompatibility with standard Jinja2
  2. Provides reproduction steps - With a properly named test macro (test_indent_compatibility)
  3. Shows expected vs actual behavior - References official Jinja2 documentation
  4. Explains the impact - Compatibility issues and user confusion
  5. Suggests a solution - Support both parameter naming conventions
  6. Includes technical context - File locations and implementation details

The issue follows the provided template and includes all necessary information for developers to understand and reproduce the problem.

Expected behavior
According to the official Jinja2 documentation, the indent filter should accept these parameters:

{{ value | indent(width=4, first=False, blank=False) }}

Where:

  • width: Number of spaces to indent (default: 4)
  • first: Whether to indent the first line (default: False)
  • blank: Whether to indent blank lines (default: False)

The macro should execute successfully and return the indented text.

Actual behavior
dbt-fusion's indent filter uses different parameter names:

  • Standard Jinja2: first → dbt-fusion: indent_first_line
  • Standard Jinja2: blank → dbt-fusion: indent_blank_lines

This requires users to rewrite their templates:

{% macro test_indent_dbt_fusion() %}
  {# Works in dbt-fusion but not standard Jinja2 #}
  {% set sample_text = "Sample description" | indent(width=6, indent_first_line=False) %}
  {{ sample_text }}
{% endmacro %}

Impact

  • Breaks compatibility with existing Jinja2 templates and macros
  • Users cannot copy examples from Jinja2 documentation
  • Creates confusion when migrating from other Jinja2-based tools
  • Documentation discrepancy leads to development friction

Proposed Solution
Update the indent filter implementation to support both parameter naming conventions:

  • Accept standard Jinja2 parameter names (first, blank) for compatibility
  • Maintain current parameter names (indent_first_line, indent_blank_lines) for backward compatibility
  • Add deprecation warnings for non-standard parameter names if desired

Screenshots
N/A

Operating System and CPU Type (please complete the following information):

  • Mac/Windows/Linux: macOS
  • X86 or ARM: ARM (Apple Silicon)

Additional context
The current implementation can be found in crates/dbt-jinja/minijinja/src/filters.rs around line 1195. This affects any template or macro that attempts to use standard Jinja2 indent filter syntax, making dbt-fusion less compatible with the broader Jinja2 ecosystem.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdiscrepancydiscrepancy between the dbt Fusion Engine and dbt Corehas-reproHas a reproducible example

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions