Accept valid bare JSON in structured response recipes
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- backend-api-design
Research direction
Start with packages/data-designer-engine/src/data_designer/engine/models/recipes/response_recipes.py and trace LLMResponseParser through packages/data-designer-engine/src/data_designer/engine/models/parsers/postprocessors.py, especially merge_text_blocks and deserialize_json_code. Run the reproduction in the issue for both recipes. Done means valid bare JSON is accepted and schema-validated as a fallback, while fenced JSON and invalid or prose-embedded responses retain their existing behavior.
Written by the indexing model from the issue text.
Description
Priority Level
Medium (Annoying but has workaround)
Describe the bug
While using Data Designer 0.9.1 for structured-output columns in NeMo Anonymizer, we encountered model responses containing valid bare JSON that were rejected because they were not wrapped in a Markdown json code fence. Wrapping the same response in a fence made it parse successfully.
This is reproducible with both PydanticResponseRecipe and StructuredResponseRecipe, without making any model calls. A formatting-only difference can therefore cause a valid structured response to fail parsing.
Steps/Code to reproduce bug
With data-designer==0.9.1 installed:
from pydantic import BaseModel
from data_designer.engine.models.recipes.response_recipes import (
PydanticResponseRecipe,
StructuredResponseRecipe,
)
class Result(BaseModel):
answer: int
raw = '{"answer": 42}'
recipes = (
PydanticResponseRecipe(data_type=Result),
StructuredResponseRecipe(json_schema=Result.model_json_schema()),
)
for recipe in recipes:
for label, response in (
("bare", raw),
("fenced", f"```json\n{raw}\n```"),
):
try:
print(type(recipe).__name__, label, "OK", recipe.parse(response))
except Exception as exc:
print(type(recipe).__name__, label, type(exc).__name__, str(exc))
Actual output:
PydanticResponseRecipe bare ParserException No parsable JSON structure within ```json markdown fence.
PydanticResponseRecipe fenced OK answer=42
StructuredResponseRecipe bare ParserException No parsable JSON structure within ```json markdown fence.
StructuredResponseRecipe fenced OK {'answer': 42}
Expected behavior
Both recipes should accept a response consisting entirely of valid bare JSON as a fallback when fenced JSON parsing finds no usable JSON block. The parsed value must still pass the recipe's existing schema validation.
Existing fenced JSON behavior should continue to work. This request does not require extracting JSON embedded in arbitrary prose or accepting schema-invalid responses.
Agent Diagnostic / Prior Investigation
- An agent ran the reproduction above against
data-designer-engine==0.9.1and confirmed the output for both recipes. - Inspected the tagged v0.9.3 source and the local main checkout at
d2470a43dcaf8c5d3babbc0fd2f8631139d40509; both recipes retain the fenced-block parsing path. - In
packages/data-designer-engine/src/data_designer/engine/models/recipes/response_recipes.py, both recipes useLLMResponseParserwithmerge_text_blocksanddeserialize_json_code, then select aStructuredDataBlockbefore schema validation. - In
packages/data-designer-engine/src/data_designer/engine/models/parsers/postprocessors.py,deserialize_json_codeprocesses onlyCodeBlockobjects whose language isjson. Bare JSON remains a text block, leaving no structured block for the recipe to validate. - Searched the current documentation and GitHub issues/PRs for bare JSON and code-fence parsing; no matching issue or documented bare-JSON fallback was found.
Additional context
We will implement the fallback and contribute a PR with regression tests for both recipes.
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
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 219
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 42
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA-NeMo/DataDesigner
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA-NeMo/DataDesigner#995 ·
Maintainers usually reply within 1 day
-
enforce \from future import annotations` via ruff FA102 rule`Possibly taken @chethanuk claimed this 27 days ago. Opentask
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
NVIDIA-NeMo/DataDesigner#760 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 63/100
NVIDIA-NeMo/DataDesigner#1001 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 53/100
NVIDIA-NeMo/DataDesigner#996 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 36/100
NVIDIA-NeMo/DataDesigner#994 ·
Maintainers usually reply within 1 day
All issues in NVIDIA-NeMo/DataDesigner
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
SR_SECURITY_DESCRIPTOR.fromString drops the SACL when no DACL is presentPossibly taken @paul7436 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
equinor/fmu-sumo-uploader#302 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
modelscope/evalscope#1821 ·
Maintainers usually reply within 1 day
-
Sanity on ansible-core devel fails: ignore-2.23.txt references the removed import-3.9 testPossibly taken @yurnov claimed this today. Openneeds_triage
Difficulty 1/5 Under an hour Newbie friendliness 91/100
ansible-collections/kubernetes.core#1275 ·
Maintainers usually reply within 1 day