Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when sync alwaysWriteFields after upgrade Gantt v6.1.5 -> v6.1.6 #10755

Open
chuckn0rris opened this issue Feb 6, 2025 · 0 comments
Open
Labels
bug Something isn't working forum Issues from forum large-account Reported by large customer OEM OEM customer premium regression Worked previously, now broken

Comments

@chuckn0rris
Copy link

Please review user's comments for details

Forum post

Hi,

An error happens whenever alwaysWriteFields needs to be synced to the server, so in some cases even on open Gantt application. Here is the console log of the error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'split')
    at _ObjectHelper.setPath (Objects.js:398:10)
    at eval (Model.js:1503:20)
    at Array.forEach (<anonymous>)
    at get modificationDataToWrite (Model.js:1502:12)
    at eval (AbstractCrudManagerMixin.js:1140:31)
    at Array.reduce (<anonymous>)
    at CDSProjectModel.prepareUpdated (AbstractCrudManagerMixin.js:1135:54)
    at CDSProjectModel.getCrudStoreChanges (AbstractCrudManagerMixin.js:1182:24)
    at eval (AbstractCrudManagerMixin.js:1237:30)
    at Array.forEach (<anonymous>)
    at get changes (AbstractCrudManagerMixin.js:1236:23)
    at get changes (ProjectCrudManager.js:126:25)
    at CDSProjectModel.getChangesetPackage [as originalGetChangesetPackage] (AbstractCrudManagerMixin.js:1202:15)
    at CDSProjectModel.getChangesetPackageHook (CDSProjectModel.ts:132:43)
    at eval (AbstractCrudManagerMixin.js:1580:25)
    at new Promise (<anonymous>)
    at CDSProjectModel.sync (AbstractCrudManagerMixin.js:1578:37)
    at eval (ProjectCrudManager.js:76:12)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (ProjectCrudManager.js:11:70)
    at _next (ProjectCrudManager.js:12:163)

Code in v6.1.6 with added comments of the values that I inspected in the debugger:

@bryntum/core-thin/lib/data/stm/Model.js v6.1.6

get modificationDataToWrite() {
    const me = this, { modificationData, constructor: ctor } = me, recordData = modificationData != null ? modificationData : {}, fields = ctor.alwaysWriteFields; // fields is a list of string
    let hasData = Boolean(modificationData);
    fields.forEach((field) => { //     ERROR: field = "readonly", that means that field.dataSource is undefined
      ObjectHelper.setPath(recordData, field.dataSource, me.getFieldPersistentValue(field));
      hasData = true;
    });
    if (hasData && !modificationData) {
      ObjectHelper.setPath(recordData, ctor.idField, me.id);
    }
    return hasData ? recordData : null;
  }

fields = ctor.alwaysWriteFields is a list of strings (print screen in the attachment)

@bryntum/core-thin/lib/helper/util/Objects.js v6.1.6

static setPath(object, path, value) {
    path.split(".").reduce((result, key, index, array) => { // ERROR: path is undefined, therefore path.split throws an error
      const isLast = index === array.length - 1;
      if (isLast) {
        return result[key] = value;
      } else if (!(result[key] instanceof Object)) {
        result[key] = {};
      }
      return result[key];
    }, object);
    return object;
  }


This is how the getter modificationDataToWrite was in the v6.1.5 where it is working fine:

@bryntum/core-thin/lib/data/stm/Model.js v6.1.5

get modificationDataToWrite() {
    const alwaysWriteFields = this.constructor.alwaysWriteFields, recordData = this.modificationData;
    alwaysWriteFields.forEach((fieldName) => {
      recordData[this.getFieldDefinition(fieldName).dataSource] = this.getFieldPersistentValue(fieldName);
    });
    return recordData;
  }

Screenshot 2025-02-06 at 13.08.24.png

@chuckn0rris chuckn0rris added bug Something isn't working forum Issues from forum large-account Reported by large customer OEM OEM customer premium regression Worked previously, now broken labels Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forum Issues from forum large-account Reported by large customer OEM OEM customer premium regression Worked previously, now broken
Projects
None yet
Development

No branches or pull requests

1 participant