TypeError: Cannot read properties of null (reading 'backupWithholdingInd') at UDF$2(JSON, JSON) line 10, columns 33-34

I am writing a Java Script Routine in BigQuery.

CREATE OR REPLACE FUNCTION `bes-np.besdevonly_auditframework.toUpdateJSONValue`(oldbean JSON, newbean JSON) RETURNS STRING LANGUAGE js AS R"""
function diff(obj1, obj2) {
    alert(obj1);
    var result = {};
    var change;
    for (var key in obj1) {
        if (typeof obj2[key] == 'object' && typeof obj1[key] == 'object') {
            change = diff(obj1[key], obj2[key]);
            if (isEmptyObject(change) === false) {
                result[key] = change;
            }
        }
        else if (obj2[key] != obj1[key]) {
            result[key] = obj2[key];
        }
    }
    return result;
}
diff(oldbean, newbean)
""";

This function supposed to be comparing 2 JSON objects and will change elements and values as a result.

When I am running on Google BigQuery - Erroring as “TypeError: Cannot read properties of null (reading ‘backupWithholdingInd’) at UDF$2(JSON, JSON) line 10, columns 33-34”

Your help is much appriciated.

Thanks

Hi @Kumar_Bandari, welcome to the community!

I am not quite sure where n8n comes into play here - can you elaborate a bit on which problem exactly you’re having with n8n, share a workflow to reproduce the problem, and confirm which version of n8n you are using?

Good morning,

Here is the workflow:

System is capturing Events - For example in UPDATE event - Entity will be changing (Here the Entity is a collection of elements in the form of JSON) - In UPDATE event We are capturing JSON object before and after change . Generating Reports using Looker Studio and BigQuery (Google Cloud). In Reports would like to compare 2 JSON objects and result of changed elements only to display.

Java Script Routine wrote - but it is not working with BigQuery.

Looking for some help - your help will be greatly appreciated.

Thanks,

Kumar

I am really sorry, but I still don’t get what exactly you are doing with n8n here. Any chance you can select the part of your workflow throwing the error on the n8n canvas, then hit Ctrl+C to copy it and past the result here on the forum?

Also, can you share a screenshot of the exact error message you are seeing in n8n, including all details?

Thank you so much!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.