Inconsistent data returned from hooks *POTENTIAL BUG* #3218
Replies: 6 comments 9 replies
-
It looks like the |
Beta Was this translation helpful? Give feedback.
-
@denolfe Came across the same issue, again... I have a CollectionAfterChange hook on my "messages" collection. "Message" records are created dynamically from other hooks, and some callbacks from an external system, and when the app is in production they will rarely if ever be created manually. However, today I created a message manually and my hook did not run, upon further investigation I realized it was the same issue as before: doc {
id: '64edf7f1605cb541757eccbe',
customer: 'CCC',
event: 'dispatchFeatureDeploy',
code: 'ccc',
status: 'in_process',
message: {
tag: '0.0.10',
stage: 'prod',
feature: 'attachments',
corpCode: 'xxx,
accountId: 'xxxxxxxxxxxxxx',
accountType: 'xxxxxxx',
correlationId: 'xxxxxxxxxxxxxxxxxx',
awsAccountRecordId: 'xxxxxxxxxxxxxxx',
originalMessageType: 'xxxxxxx'
},
createdAt: '2023-08-29T13:51:45.925Z',
updatedAt: '2023-08-29T13:51:45.925Z'
} Returned "doc" from dynamically creating same message: doc {
id: '64edf924a3f22971c3d90cd4',
customer: {
id: 'CCC',
name: 'test c',
type: 'school',
county: {
id: 'IN-3',
state: 'IN',
name: 'Bartholomew',
code: 3,
timezone: 'US/Eastern'
},
createdAt: '2023-08-07T13:54:25.876Z',
updatedAt: '2023-08-07T13:54:25.876Z'
},
event: {
id: 'dispatchFeatureDeploy',
description: 'Feature deploy workflow (currently only "low-attachments") will be dispatched on the creation of this message, either for a feature enabled or for a feature updated on the existing account.',
queue: {
id: 'infrastructureAutomation',
description: 'Event messages that should result in infrastructure being provisioned should be placed in this queue.',
settings: [Object],
_status: 'published',
createdAt: '2023-08-01T14:43:14.987Z',
updatedAt: '2023-08-01T14:43:14.987Z'
},
priority: 5,
messageSchema: {
tag: [Object],
stage: [Object],
feature: [Object],
corpCode: [Object],
accountId: [Object],
accountType: [Object],
correlationId: [Object],
awsAccountRecordId: [Object],
originalMessageType: [Object]
},
_status: 'published',
createdAt: '2023-08-17T16:41:41.179Z',
updatedAt: '2023-08-17T16:41:41.179Z'
},
code: 'ccc',
status: 'in_process',
message: {
corpCode: 'xxxxxx',
accountId: 'xxxxxxxxxxxxxxxxxxx',
correlationId: 'xxxxxxxxxxxxxxxxxxx',
awsAccountRecordId: 'xxxxxxxxxxx',
originalMessageType: 'xxxxxxxxxx',
accountType: 'xxxxxxxxxxxx',
tag: xxxxx,
feature: 'xxxxxxxxxx',
stage: 'xxxxx'
},
createdAt: '2023-08-29T13:56:52.639Z',
updatedAt: '2023-08-29T13:56:52.639Z'
} |
Beta Was this translation helpful? Give feedback.
-
Let me convert this to a possible issue, so it can get looked at. |
Beta Was this translation helpful? Give feedback.
-
I can second this issue. Happens as well when checking user in access control, takes a second or a refresh for the full object to pop through, otherwise checking roles can cause the admin panel to crash without proper null checking |
Beta Was this translation helpful? Give feedback.
-
@MarkAtOmniux @wrobson-lllow We recently rolled out a fix for this issue but are going to be reverting it in 2.0. The admin panel uses depth=0 when submitting data, hooks will need to account for any depth by type checking the relationship and fulfilling them if needed. |
Beta Was this translation helpful? Give feedback.
-
I'm still not quite following what the proper way to handle this, I had a filed a bug pre-2.0 related to this and as it happens a bunch of my hooks did break on 2.0 upgrade. I'm going to try this again with the beforeOperation, but some official guidance would be awesome! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is something I have come across several times over the last several months, but has never been a big issue, and typically the fix is as easy as checking the type before accessing the value. However, it definitely seems off...
I have a CollectionAfterChangeHook on my "license" collection where I need to access the value for "customer" (in this case "DDD") however depending where the hook is invoked changes the format of the data. The following data is from console.logging the "doc" arg:
If the hook is invoked from a direct change on the "license" collection (i.e. a user updates a value manually) the following is passed to the hook as the "doc" argument:
However, I have a CollectionAfterDeleteHook on a separate collection that updates the "options" field on the "licenses" collection. When the "licenses" CollectionAfterChangeHook is invoked via a change made by the CollectionAfterDeleteHook the following is what is passed to the hook as the "doc" argument:
Beta Was this translation helpful? Give feedback.
All reactions