Skip to content

Plugin not working together with @cap-js/attachments plugin #197

@gecko17

Description

@gecko17

This plugin is introducing a side effect in the following line:

const assoc = { ...changes, on: [ ...changes.on, ...keys ] }

The reason is, that you are copying the properties of an object, but not the functions.

The following @sap/cds function is expecting this object to have an .is function, which then causes an error:
line 140 in @sap/cds/lib/core/linked-csn.js

The @cap-js/attachments plugin for instance is invoking this code through this line and hence running into this issue: https://github.com/cap-js/attachments/blob/main/lib/plugin.js#L13

To reproduce the issue:

  1. Create a CAP project with both plugins @cap-js/attachments and @cap-js/change-tracking.
  2. Make sure that the dependency of the change-tracking plugin is listed after the attachment plugin in the dependencies of the package.json
  3. The reason for this is, that both plugins are registering a handler for the compile.to.edmx event and the handlers are executed in the registration order. Only when the change-tracking plugin code runs first, the issue occurs.

Solution would be to create a deep copy of the object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions