Skip to content

fix(worker): align patchConfig with the API on key removal - #110

Merged
albanm merged 2 commits into
masterfrom
fix-patch-config-null-unset
Sep 8, 2026
Merged

fix(worker): align patchConfig with the API on key removal#110
albanm merged 2 commits into
masterfrom
fix-patch-config-null-unset

Conversation

@BatLeDev

@BatLeDev BatLeDev commented Sep 7, 2026

Copy link
Copy Markdown
Member

A plugin calling patchConfig({ someKey: null }) had its null stored as-is: the worker merged the patch with Object.assign, so a key could never be reset. The API's PATCH /processings/:id already treats a top-level null as a removal, and validates the resulting config against the plugin's config schema — so a null written by a run left the document invalid for the very endpoint that would save it next (400 on the next save from the UI).

In patchConfig (worker/src/task/task.ts), iterating over patch entries now deletes keys whose value is null or undefined from the in-memory config instead of assigning them.

Why: the worker and the API were writing the same document under two different conventions; the worker should at least be aligned with the API.

Heads-up: undefined now deletes the key too. Several plugins already use that idiom ({ datasetMode: 'update', datasets: undefined }) and it already behaved that way in the database, since the mongo client is built with ignoreUndefined: true; the in-memory config the run reads is now consistent with what gets stored. Existing documents that already hold a null in their config are not cleaned up by this change.

The worker's patchConfig did a plain Object.assign into the processing
config, so a plugin had no way to reset a config key and a null ended up
stored as-is. The API's PATCH already treats null as a removal ($unset),
and validates the resulting config against the plugin's config schema —
so a null written by a run left the document invalid for the very
endpoint that would save it next (400 on the next save from the UI).

Align the two: extract the merge into applyConfigPatch, where a null
value deletes the key, and unit test the semantics. Undefined deletes it
too — plugins already use that idiom and the mongo client, built with
ignoreUndefined, already dropped those keys on write; the in-memory
config now matches what is stored.
@github-actions github-actions Bot added the fix label Sep 7, 2026
@github-actions github-actions Bot added fix and removed fix labels Sep 7, 2026
@albanm
albanm merged commit f808ced into master Sep 8, 2026
4 checks passed
@albanm
albanm deleted the fix-patch-config-null-unset branch September 8, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants