Skip to content

change: simplify placeholder strategy to only use non-controversial empty values#2

Merged
metalwarrior665 merged 1 commit into
masterfrom
claude/safepushdata-placeholder-values-m9ncfy
Jul 24, 2026
Merged

change: simplify placeholder strategy to only use non-controversial empty values#2
metalwarrior665 merged 1 commit into
masterfrom
claude/safepushdata-placeholder-values-m9ncfy

Conversation

@metalwarrior665

Copy link
Copy Markdown
Member

Summary

This PR significantly simplifies the data repair strategy in safePushData by 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 type keyword 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 uses null as 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 / exclusiveMaximum
    • enum (first allowed value)
    • format (email, URI, date, UUID, etc.)
  • Updated tests: Modified test cases to reflect the new behavior:

    • Tests that previously expected items to be pushed with fabricated values now expect items to be dropped
    • Added new test for union types with null
    • Updated test descriptions to clarify the rationale
  • 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:

  1. Only processes type errors
  2. Prefers null for union types that include it
  3. Falls back to empty values for single types
  4. Returns { ok: false } for everything else, causing the item to be dropped

This 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

…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
@metalwarrior665 metalwarrior665 changed the title Simplify placeholder strategy to only use empty values change: simplify placeholder strategy to only use non-controversial empty values Jul 23, 2026
@metalwarrior665
metalwarrior665 merged commit b9a7d0b into master Jul 24, 2026
13 of 15 checks passed
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.

3 participants