adobe/helix-shared

context.invocation might not exist

dominique-pfister opened this issue ยท 6 comments

If I use the new helix-shared version, add a .with(requiredConfig, 'fstab') in my code and run my test function, it stumbles on the following line:

const {
transactionId,
} = context.invocation;

with a TypeError: Cannot destructure property 'transactionId' of 'context.invocation' as it is undefined.

If I add the .. || {}; alternative as in helix-universal-logger:

https://github.com/adobe/helix-universal-logger/blob/edf721720a53ef85cbe43cfaa1ca6df36c20dcb3/src/logger.js#L178-L180

everything runs fine and I get a fstab in my context.config. ๐Ÿค—

๐ŸŽ‰ This issue has been resolved in version 7.29.1 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€

I think you'd rather need to fix your test code. as context.invocation is a mandatory object.....

Then why did you add that alternative in helix-universal-logger?

I also checked existing code, e.g. https://github.com/adobe/helix-content-proxy/blob/main/test/utils.js where retrofit is mocking a context, but no invocation is set up there, either.

Then why did you add that alternative in helix-universal-logger?

probably because of the same reason...i wanted the tests to work ;-)

I also checked existing code, e.g. https://github.com/adobe/helix-content-proxy/blob/main/test/utils.js where retrofit is mocking a context, but no invocation is set up there, either.

probably forgot.