-
Notifications
You must be signed in to change notification settings - Fork 3
Update _key generation #33
base: main
Are you sure you want to change the base?
Update _key generation #33
Conversation
@@ -41,7 +53,7 @@ export function createUserEntity(user: any): Entity { | |||
...convertCommonServiceNowProperties(user), | |||
_class: Entities.USER._class, | |||
_type: Entities.USER._type, | |||
_key: user.sys_id, | |||
_key: getUserKey(user.sys_id, user.user_name), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have examples of where this fixed the duplicate key issue? I'm surprised the id
wasn't unique.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to confirm that this fixes the issue, because changing the _key
value will cause a large amount of churn in users' graphs. If we can avoid that it's better, but does fix the issue I'm good to go with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @zemberdotnet, we aren't 100% sure if this will fix the issue but we thought it was worth a try - weren't aware changing _key
has negative impact as a whole on the other hand.
The code surrounding user ingestion is very simple:
Client method part:
return this.iterateTableResources({
table: ServiceNowTable.USER,
callback,
});
Step function part:
await client.iterateUsers(async (user) => {
const userEntity = await jobState.addEntity(createUserEntity(user));
await jobState.addRelationship(
createDirectRelationship({
_class: RelationshipClass.HAS,
from: accountEntity,
to: userEntity,
}),
);
});
Some ideas that came to mind were either to increase the _key
complexity or to maybe skip (truly) duplicate users but it's not like we're expecting them by default and that alone might hide some other bug that's causing this.
Do you have some ideas what you might try doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @eXtremeX 👋 Thank you for the detailed explanation.
weren't aware changing _key has negative impact as a whole on the other hand.
In this case, it's probably okay. It will cause all entities to be fully deleted and recreated, but this probably doesn't produce enough data for that to be a huge concern.
I'm good to try this approach if we can address the other comment I have below.
@@ -4,7 +4,7 @@ const instanceConfigFields: IntegrationInstanceConfigFieldMap = { | |||
hostname: { | |||
type: 'string', | |||
}, | |||
username: { | |||
userid: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, last problem before this can be approved. Do we have to change this field name? It will cause breaking changes and require migration for all integrations that use this field.
Summary
Added
user
,group
andincident
keys more detailed by including thename
/email
property.Updated
USERNAME
property name toUSERID
.sys_id
may be unique only to the table it is on, meaning different tables can have entries with the samesys_id
.sys_id
and the name of the entity to generate the key..env
file, wherein theUSERNAME
parameter was not being properly detected. To fix this, the parameter was renamed toUSERID
instead.Type of change
Please leave any irrelevant options unchecked.
not work as expected)
Checklist
General Development Checklist: