Skip to content

fix: escape single quotes in the seed dataset SQL literal - #1109

Closed
xubenqiang wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
xubenqiang:fix/escape-seed-path-sql-literal
Closed

xubenqiang wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
xubenqiang:fix/escape-seed-path-sql-literal

Conversation

@xubenqiang

Copy link
Copy Markdown

Fixes #1102

What changed

SeedReader built DuckDB SQL by interpolating self.get_dataset_uri() into single-quoted string literals, so a local seed under a path containing ' (for example o'brien/seed.parquet) ended the literal early and DuckDB raised a parser error.

The URI now goes through one _as_sql_literal() helper that doubles embedded single quotes, and all four sites use it: get_seed_dataset_size, get_column_names and both branches of build_dataset_read_query.

Files:

  • packages/data-designer-engine/src/data_designer/engine/resources/seed_reader.py
  • packages/data-designer-engine/tests/engine/resources/test_seed_reader.py

Testing

$ python -m pytest packages/data-designer-engine/tests/engine/resources/test_seed_reader.py -q
53 passed, 1 failed

The new test writes a parquet seed under o'brien/, attaches a LocalFileSeedReader and checks get_seed_dataset_size() / get_column_names():

$ python -m pytest .../test_seed_reader.py -q -k escapes_single_quotes
1 passed

With the source change reverted it fails with the reported error:

_duckdb.ParserException: Parser Error: syntax error at or near "\"

The one remaining failure in the file, test_filesystem_seed_reader_uses_injected_filesystem_provider, also fails on the unmodified checkout here because it expects remote-root/alpha.txt while Windows joins with a backslash; it is unrelated to this change.

AI assistance

Prepared with an AI coding agent (DeepSeek Harness / deepseek-flash) and verified with the runs above.

SeedReader interpolated the dataset URI into DuckDB string literals without
escaping embedded single quotes, so a local seed under a path such as
o'brien/ failed with a parser error.

Quote the URI through one helper that doubles embedded quotes and use it in all
four query sites (count, describe, and both read branches).

Fixes NVIDIA-NeMo#1102
@xubenqiang
xubenqiang requested a review from a team as a code owner October 28, 2026 18:40
Copilot AI balanced review requested due to automatic review settings October 28, 2026 18:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions

Copy link
Copy Markdown
Contributor

Linked Issue Check

Issue #1102 has not been triaged yet. A maintainer needs to review
the issue and add the triaged label.

New or reopened PRs without a triaged issue are closed. Check the
issue for the triaged label; you may reopen this PR after a
maintainer adds it.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your submission! We ask that you sign our Developer Certificate of Origin before we can accept your contribution. You can sign the DCO by adding a comment below using this text:


I have read the DCO document and I hereby sign the DCO.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the DCO Assistant Lite bot.

@github-actions github-actions Bot closed this Oct 28, 2026
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The PR affects seed dataset queries used in data-generation workflows.

The PR appears safe to merge, with a non-blocking error-message text regression.

Findings

  1. P2 Error messages show garbled text ▶
Fix with agent prompt
### Issue 1
packages/data-designer-engine/src/data_designer/engine/resources/seed_reader.py:96
The two error messages replace `🛑` with the garbled text `馃洃`. Users see these characters when a seed directory is missing or an agent rollout reader gets a non-local path. Restore `🛑` here and in the message at line 783.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR fixes seed paths containing single quotes by using _as_sql_literal in all four SQL query sites.

  • Seed reads keep apostrophes inside dataset paths.
  • Filesystem setup errors display a different warning marker.

xubenqiang reports that the filesystem-provider test also fails on the unmodified Windows checkout because of path separators; this PR does not change that behavior.

Reviews (1) · Last reviewed commit: "fix: escape single quotes in the seed da..." · Reviewed by Greptile

resolved_root_path = Path(runtime_path).expanduser().resolve()
if not resolved_root_path.is_dir():
raise SeedReaderConfigError(f"🛑 Seed source directory '{resolved_root_path}' does not exist.")
raise SeedReaderConfigError(f"馃洃 Seed source directory '{resolved_root_path}' does not exist.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Error messages show garbled text

The two error messages replace 🛑 with the garbled text 馃洃. Users see these characters when a seed directory is missing or an agent rollout reader gets a non-local path. Restore 🛑 here and in the message at line 783.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/data-designer-engine/src/data_designer/engine/resources/seed_reader.py
Line: 96

Comment:
**Error messages show garbled text**

The two error messages replace `🛑` with the garbled text `馃洃`. Users see these characters when a seed directory is missing or an agent rollout reader gets a non-local path. Restore `🛑` here and in the message at line 783.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

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.

Local seed path containing a single quote breaks the DuckDB query

2 participants