change: simplify placeholder strategy to only use non-controversial empty values#2
Merged
metalwarrior665 merged 1 commit intoJul 24, 2026
Conversation
…unions
Only fabricate the four unambiguously-empty placeholder values — '' (string),
[] (array), {} (object), and null — when healing a required field. Stop
placeholdering enum, format, minLength/maxLength, numeric bounds, and
integer/number/boolean types: a made-up email, first-enum-value, or fabricated
number silently poisons the customer's dataset with plausible-looking junk, so
those items are now dropped instead.
When a field allows multiple types (e.g. [string, null]), always pick null —
the cleanest placeholder, committing to no concrete value.
Also add a NOTE that we could parse dataset_schema.json and one-shot the fix
instead of recursively healing, at the cost of heavier code.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BBjhQUKX8hoFERqqpoAiQZ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR significantly simplifies the data repair strategy in
safePushDataby restricting placeholders to only the four unambiguously empty values ('',[],{},null). Previously, the code attempted to fabricate plausible values for various constraints (e.g.,minLength,enum,format), which could silently inject incorrect data into customer datasets.Key Changes
Restricted placeholder values: Only
typekeyword errors are now handled, and only for the four empty types (string, array, object, null). All other constraints cause items to be dropped instead of being "fixed" with fabricated data.Union type handling: When a field allows multiple types including
null, the placeholder now always usesnullas it's the cleanest possible placeholder that commits to no concrete value.Removed fabrication logic: Deleted code that generated placeholder values for:
minLength/maxLength(e.g.,'_'.repeat(N))minimum/maximum/exclusiveMinimum/exclusiveMaximumenum(first allowed value)format(email, URI, date, UUID, etc.)Updated tests: Modified test cases to reflect the new behavior:
Updated documentation: Simplified the README table to show only the four empty placeholder values and explain why other constraints result in item drops.
Implementation Details
The
placeholderFor()function was refactored from a large switch statement handling many keywords to a focused implementation that:typeerrorsnullfor union types that include it{ ok: false }for everything else, causing the item to be droppedThis approach prioritizes data integrity over repair attempts, avoiding the silent injection of plausible-looking but incorrect data into customer datasets.
https://claude.ai/code/session_01BBjhQUKX8hoFERqqpoAiQZ