fix: code validator false positives and null property removal (#294, #293, #611) (#637)

- Fix $() node reference triggering "Invalid $ usage" warning by adding ( and _ to regex lookahead
- Fix helper function primitive returns triggering "Cannot return primitive values" error
- Fix null values in diff engine causing Zod validation errors — null now deletes properties
- Update property removal docs from undefined to null

Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Romuald Członkowski
2026-03-15 11:26:44 +01:00
committed by GitHub
parent 599bc664d0
commit 65ab94deb2
16 changed files with 339 additions and 89 deletions

View File

@@ -1237,15 +1237,21 @@ export class WorkflowDiffEngine {
private setNestedProperty(obj: any, path: string, value: any): void {
const keys = path.split('.');
let current = obj;
for (let i = 0; i < keys.length - 1; i++) {
const key = keys[i];
if (!(key in current) || typeof current[key] !== 'object') {
if (!(key in current) || typeof current[key] !== 'object' || current[key] === null) {
if (value === null) return; // parent path doesn't exist, nothing to delete
current[key] = {};
}
current = current[key];
}
current[keys[keys.length - 1]] = value;
const finalKey = keys[keys.length - 1];
if (value === null) {
delete current[finalKey];
} else {
current[finalKey] = value;
}
}
}