Skip to content

DataDesigner.validate raises ValueError for valid Jinja prompts containing literal braces #904

Description

@andreatnvidia

Priority Level

Medium (Annoying but has workaround)

Describe the bug

DataDesigner.validate() raises an uncaught ValueError when an LLM prompt or system prompt contains an unmatched literal brace that is valid as Jinja text.

Validation passes each prompt through string.Formatter().parse() to detect f-string-style references. Python's formatter rejects unmatched braces before Data Designer can return its normal validation result.

Example error:

ValueError: Single '}' encountered in format string

Steps/Code to reproduce bug

from pathlib import Path

from data_designer.config.column_configs import LLMTextColumnConfig, SamplerColumnConfig
from data_designer.config.config_builder import DataDesignerConfigBuilder
from data_designer.config.models import ChatCompletionInferenceParams, ModelConfig, ModelProvider
from data_designer.config.sampler_params import CategorySamplerParams, SamplerType
from data_designer.engine.secret_resolver import PlaintextResolver
from data_designer.interface.data_designer import DataDesigner


builder = DataDesignerConfigBuilder(
    model_configs=[
        ModelConfig(
            alias="stub-model",
            model="stub-model",
            provider="stub-provider",
            inference_parameters=ChatCompletionInferenceParams(),
        )
    ]
)
builder.add_column(
    SamplerColumnConfig(
        name="topic",
        sampler_type=SamplerType.CATEGORY,
        params=CategorySamplerParams(values=["science"]),
    )
)
builder.add_column(
    LLMTextColumnConfig(
        name="story",
        model_alias="stub-model",
        prompt="Write about {{ topic }}. End with a literal } brace.",
    )
)

designer = DataDesigner(
    artifact_path=Path("artifacts"),
    model_providers=[
        ModelProvider(
            name="stub-provider",
            endpoint="https://example.invalid/v1",
            api_key="unused",
        )
    ],
    secret_resolver=PlaintextResolver(),
)

designer.validate(builder)

No provider request is required. The call raises ValueError: Single '}' encountered in format string.

Expected behavior

Literal braces that are valid Jinja text should not break the f-string-reference advisory check. Validation should either succeed or return a normal Data Designer validation violation, not leak an exception from string.Formatter.

Agent Diagnostic / Prior Investigation

Reproduced through the public DataDesigner.validate() method on the current main branch. A normal Jinja prompt such as Write about {{ topic }}. succeeds as a negative control.

packages/data-designer-engine/src/data_designer/engine/validation.py calls _get_string_formatter_references() for each prompt. That helper iterates over Formatter().parse(template) without handling ValueError, so the advisory check can abort the full validation path.

The issue tracker was searched for Formatter().parse, unmatched braces, literal braces, and prompt validation. Related Jinja validation issues concern different failure modes and are not duplicates.

Additional context

The f-string advisory is secondary validation and should not reject syntax accepted by the configured Jinja renderer. Regression coverage should include both { and } literals in prompts and system prompts through the public validation API.

Checklist

  • I reproduced this issue or provided a minimal example
  • I searched the docs/issues myself, or had my agent do so
  • If I used an agent, I included its diagnostics above

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions