Skip to content

Studio: do not upload the seed token when publishing a dataset - #11230

Merged
Lyxot merged 4 commits into
unslothai:mainfrom
NilayYadav:recipe-publish-scrub-seed-token
Sep 18, 2026
Merged

Lyxot merged 4 commits into
unslothai:mainfrom
NilayYadav:recipe-publish-scrub-seed-token

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

When a recipe uses a Hugging Face or GitHub token in its seed block, that token is saved in the run's builder_config.json. Publish to Hugging Face uploaded that file as is, so anyone who could see the dataset repo could read the token.

Publish now uploads a copy of the file with the token removed. The dataset card gets the same cleaned copy. The file on your own disk is not changed, so re-running the recipe still works.

Tested by publishing a recipe from Studio to a private Hub repo before and after, then downloading the uploaded file. Before, the token was in it. After, it is gone and the rest of the config is intact.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Reproduction and fix verification

Two kinds of evidence: a CI A/B on the publish path, and a real end-to-end publish to the Hugging Face Hub.

1. A/B on GitHub Actions

Same workflow, same probe, same dependencies on both branches. The only difference is studio/backend/core/data_recipe/huggingface.py: the negative branch carries the version currently on main, the positive branch carries this PR.

Branch Implementation Probe PR test file Run
pr11230-repro-before-… main REPRO: FAIL — the seed token reaches the Hugging Face dataset repo 6 of 7 failed 35275963568 (failure)
pr11230-repro-after-… this PR REPRO: PASS — no seed token leaves the machine, local file untouched 7 passed 35275748268 (success)

Negative-branch log:

implementation=UNFIXED (pre-PR publish path)
seed token in uploaded builder_config.json : True
seed token in uploaded dataset card        : True
seed token still on local disk (must be True): True
REPRO: FAIL - the seed token reaches the Hugging Face dataset repo

Positive branch, same probe:

implementation=FIXED
seed token in uploaded builder_config.json : False
seed token in uploaded dataset card        : False
seed token still on local disk (must be True): True
REPRO: PASS - no seed token leaves the machine, local file untouched

2. Real publish to the Hub

publish_recipe_dataset was run for real on both implementations — real data_designer 0.9.2 HuggingFaceHubClient, real upload to a private dataset repo — and builder_config.json was then downloaded back from the Hub. The seed token was the placeholder hf_FAKE_SEED_TOKEN_FOR_PR11230_EVIDENCE; both repos have been deleted.

BEFORE (main), file as served by the Hub:

"seed_config": {
  "source": {
    "seed_type": "hf",
    "path": "datasets/acme/private-seed/data/*.parquet",
    "token": "hf_FAKE_SEED_TOKEN_FOR_PR11230_EVIDENCE"
  },
  "sampling_strategy": "ordered"
}

AFTER (this PR), same request:

"seed_config": {
  "source": {
    "seed_type": "hf",
    "path": "datasets/acme/private-seed/data/*.parquet"
  },
  "sampling_strategy": "ordered"
}

Nothing else about the published dataset moved: both repos contained the same five paths (.gitattributes, README.md, builder_config.json, data/batch_000.parquet, metadata.json), metadata.json was byte-identical, and the two dataset cards differed only in the repo name. The local builder_config.json still held the token on both sides, so re-running the recipe is unaffected.

@Lyxot Lyxot self-assigned this Sep 18, 2026
…ecipe dataset

builder_config.json is always written as BuilderConfig(data_designer=...), and the hf and github_repo seed sources store a flat token field, so remove that one key instead of every nested token under an unwrapped or wrapped config. Tests cover the two real sources, the real file shape, and a recipe without a seed.
@Lyxot

Lyxot commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Pushed 536571a on top: builder_config.json is always written wrapped under data_designer, and only the hf and github_repo seed sources carry a flat token, so the scrub now drops just data_designer.seed_config.source.token instead of recursively removing every nested token under both shapes. Tests now cover the two real sources, the real file shape, and a recipe without a seed (seed_config: null). Verified against the real Data Designer 0.5.4 client with only HfApi mocked: main uploads the token, this branch does not, and the local file is unchanged.

@Lyxot

Lyxot commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Codex review on a staging copy of this branch (head 536571a merged onto main), since the connector is not responding here: Didn't find any major issues — Lyxot#56 (comment)

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Fixes a real leak: the hf and github_repo seed tokens in builder_config.json were uploaded to the Hub as-is. The token is now dropped from an uploaded copy only, the local artifact is untouched, and recipes without a seed or without a builder config publish as before. Verified end to end against the real Data Designer 0.5.4 client; Studio tests and Codex review are clean, and the remaining CI failures are unrelated flaky tests.

@Lyxot
Lyxot merged commit 7c5ce34 into unslothai:main Sep 18, 2026
39 of 41 checks passed
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…thai#11230)

* Studio: keep the seed block's token out of the published builder_config.json

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Tests: assert metadata still uploads when there is no builder config

* refactor(studio): drop only the seed source token when publishing a recipe dataset

builder_config.json is always written as BuilderConfig(data_designer=...), and the hf and github_repo seed sources store a flat token field, so remove that one key instead of every nested token under an unwrapped or wrapped config. Tests cover the two real sources, the real file shape, and a recipe without a seed.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Lyxot <[email protected]>
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.

2 participants