Skip to content

Add additional test coverage for PDD tag brace escaping fix #417

@jamesdlevine

Description

@jamesdlevine

Context

The fix in fix/preprocess-pdd-tag-escaping branch (commit dccc04b) addresses the bug where <pdd-interface> JSON braces in included files were not being escaped for str.format() safety. The fix added 14 new regression tests and updated 6 existing tests (91 tests now pass).

However, there are additional edge cases and scenarios that should be tested for full coverage.

Recommended Additional Tests

1. Backtick-style includes with PDD tags

The current tests only cover <include> but not the backtick ```<file.txt>``` style includes:

def test_backtick_include_with_pdd_tags_is_format_safe():
    """Test ```<file.txt>``` style includes with PDD tag content."""

2. Recursive/nested includes with PDD tags

What happens when an included file itself has <include> tags that bring in more PDD content?

def test_nested_includes_with_pdd_tags_are_format_safe():
    """Test that nested includes (file A includes file B which has PDD tags) work."""

3. Already-escaped braces in PDD source content

What if the original PDD content already contains {{ before preprocessing?

def test_already_escaped_braces_in_pdd_content():
    """Test PDD content that already has {{escaped}} braces doesn't get quadrupled."""

4. Empty and whitespace-only PDD tags

def test_empty_pdd_interface_tag_is_format_safe():
    """Test <pdd-interface></pdd-interface> doesn't break format()."""

def test_whitespace_only_pdd_interface_is_format_safe():
    """Test <pdd-interface>   </pdd-interface> is handled correctly."""

5. PDD tags at file boundaries

def test_pdd_tag_at_start_of_included_file_is_format_safe():
    """Test included files that start directly with <pdd-interface>."""

def test_pdd_tag_at_end_of_included_file_is_format_safe():
    """Test included files that end with </pdd-interface> (no trailing newline)."""

6. Unicode/special characters in PDD JSON

def test_unicode_in_pdd_interface_is_format_safe():
    """Test PDD interface with Unicode characters like {"name": "日本語"}."""

7. Integration test with actual temp files (not mocks)

The current tests all use mock_open. A real filesystem test would catch issues the mocks might miss:

def test_real_file_include_with_pdd_tags_integration(tmp_path):
    """Integration test with actual temp files instead of mocks."""

8. End-to-end test: preprocess → parse_prompt_tags → format()

def test_full_pipeline_preprocess_then_parse_then_format():
    """Test the complete flow: preprocess includes PDD content, 
    parse_prompt_tags extracts it, format() replaces placeholders."""

9. ValueError from malformed escape sequences

def test_format_valueerror_from_incomplete_escape():
    """Test content like '{ unclosed' or 'trailing }' doesn't crash."""

10. PDD tags mixed with other preprocessor directives

def test_pdd_tags_with_shell_and_web_tags():
    """Test <pdd-interface> mixed with <shell> and <web> tags."""

Priority

These are recommended improvements rather than critical bugs. The current fix addresses the core issue and the existing 91 tests provide good coverage. These additional tests would improve confidence in edge cases.

Related

  • Branch: fix/preprocess-pdd-tag-escaping
  • Commit: dccc04b (fix: Escape braces in PDD tags for str.format() safety)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions