Skip to content

Fix Transformation Strategy 'null' - #170

Open
GALHP wants to merge 20 commits into
clonio-dev:mainfrom
GALHP:fix/transformation-strategy-null
Open

Fix Transformation Strategy 'null'#170
GALHP wants to merge 20 commits into
clonio-dev:mainfrom
GALHP:fix/transformation-strategy-null

Conversation

@GALHP

@GALHP GALHP commented Aug 13, 2026

Copy link
Copy Markdown

Summary

Fixes a bug where the null column strategy (set a column to SQL NULL) is
written unquoted into a generated .cloning.yaml, so the next cloning:run
fails validation.

Stacked PR — base: feat/remapping-keys-as-config-option · 6th of 6 · Part of #164.
No code dependency on #165#168 (stacked only)

The bug

The PII baseline defines a null strategy
(gender: { transformation: { strategy: 'null' } }). cloning:dump serialized
it with a bare sprintf, emitting the string "null" unquoted
strategy: null. YAML reads that as the null literal, not "null", so the next
cloning:run aborts in Phase-1 validation:

Table '…', column 'gender': strategy must be one of:
keep, fake, hash, mask, null, static, template, remapping

(Even bypassing validation, the loader coerced the null literal to keep, so
the column wouldn't be nulled.)

The fix

CloningYamlWriter now serializes the column strategy through its existing
encodeYamlScalar() helper, which already quotes values colliding with YAML
literals (null, true, …). It emits strategy: "null", which round-trips as
the string "null" — validation passes and AnonymizationEngine maps 'null'
to SQL NULL. Other strategies are unchanged. One-line change scoped to the buggy
line, general for any future literal-colliding value.

Testing

CloningYamlWriterTest adds a null-strategy case: asserts the quoted output,
and a round-trip regression — the written YAML loads back with
strategy === 'null' (not 'keep') and CloningYamlValidator returns no
errors. Verified end-to-end: gender dumps as strategy: "null", cloning:run
validates and completes, target column is NULL.

GALHP added 20 commits July 24, 2026 16:31
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.

1 participant