cap-js / audit-logging

CDS plugin providing integration to the SAP Audit Log service as well as out-of-the-box personal data-related audit logging based on annotations.
https://cap.cloud.sap/docs/guides/data-privacy
Apache License 2.0
4 stars 1 forks source link

@cap-js/audit-logging: 0.8.0 causes server crash #107

Closed Divya-Shanmugamb closed 1 month ago

Divya-Shanmugamb commented 1 month ago

Hi,

In the Incidents-app, we have added cap-js/audit-logging which has v0.8.0. We have added @cap-js/change-tracking by running 'npm add @cap-js/change-tracking'. After adding change-tracking, @sap/cds version is downgraded from 8v to 7.9.4v. Due to which the server is crashing.

With @sap/cds 7.9.4v, @cap-js/audit-logging 0.8.0v, the server is crashing is below error.

> @capire/incidents@1.0.0 start
> cds-serve

{"level":"info","logger":"cds","timestamp":"2024-08-05T08:32:08.225Z","msg":"loaded model from 8 file(s):\n\u001b[2m","type":"log"}
  srv/data-privacy.cds
  srv/change-tracking.cds
  node_modules/@cap-js/change-tracking/index.cds
  app/services.cds
  app/incidents/annotations.cds
  srv/services.cds
  db/schema.cds
  node_modules/@sap/cds/common.cds

{"level":"info","logger":"cds","timestamp":"2024-08-05T08:32:08.503Z","msg":"using auth strategy { kind: 'jwt', impl: 'node_modules/@sap/cds/lib/auth/jwt-auth' } \n","type":"log"}
{"level":"info","logger":"cds","timestamp":"2024-08-05T08:32:08.854Z","msg":"serving ProcessorService { impl: 'srv/services.js', path: '/odata/v4/processor' }","type":"log"}
{"level":"info","logger":"cds","timestamp":"2024-08-05T08:32:08.855Z","msg":"serving AdminService { impl: 'srv/services.js', path: '/odata/v4/admin' }","type":"log"}
/Users/I584724/Documents/externalcap/incidents-app/node_modules/@cap-js/audit-logging/cds-plugin.js:46
      db.before(WRITE, entity, addDiffToCtx)
         ^

TypeError: Cannot read properties of undefined (reading 'before')
    at cds.<anonymous> (/Users/I584724/Documents/externalcap/incidents-app/node_modules/@cap-js/audit-logging/cds-plugin.js:46:10)
    at cds.emit (/Users/I584724/Documents/externalcap/incidents-app/node_modules/@sap/cds/lib/index.js:13:70)
    at async cds_server (/Users/I584724/Documents/externalcap/incidents-app/node_modules/@sap/cds/server.js:41:3)
    at async Object.serve (/Users/I584724/Documents/externalcap/incidents-app/node_modules/@sap/cds/bin/serve.js:191:18)

Result of cds -v @cap-js/audit-logging: 0.8.0 @cap-js/cds-types: 0.2.0 @cap-js/change-tracking: 1.0.6 @cap-js/sqlite: 1.7.3 @capire/incidents: 1.0.0 @sap/cds: 7.9.4 @sap/cds-compiler: 4.9.8 @sap/cds-dk (global): 7.9.6 @sap/cds-fiori: 1.2.7 @sap/cds-foss: 5.0.1 @sap/cds-mtxs: 1.18.2 @sap/eslint-plugin-cds: 3.0.4 Node.js: v20.15.1 home: /Users/I584724/Documents/externalcap/incidents-app/node_modules/@sap/cds

Raised a ticket under @cap-js/change-tracking. Attaching the ticket for reference - https://github.com/cap-js/change-tracking/issues/102

Regards, Divya

sjvans commented 1 month ago

hi @Divya-Shanmugamb

thanks for reporting. however, @cap-js/audit-logging does not require cds^8; cds>=7 is fine. also, i cannot reproduce the issue. cds version is downgraded as described in https://github.com/cap-js/change-tracking/issues/102, but still the server starts without an issue... so i'd need more information. please reopen with detailed instructions if the issue persists.

fyi, https://github.com/cap-js/change-tracking/issues/102 will be resolved soon.

best, sebastian