Page MenuHomePhabricator

output-sql.js throws an error if actor.client does not exist in the dataset
Closed, DeclinedPublic

Description

This was noticed in T351197#9447809.

output-sql.js assumes that actor.client is not undefined:

function generateInsertActorQueries( actor ) {
	const actorObj = {
		actor_data: {
			ip: actor.ip,
			org: actor.organization,
			client_count: actor.client.count || 0,
			types: actor.client.types ?
				getActorTypes( actor.client.types ) : actorTypes.UNKNOWN,
			conc_city:
				actor.client.concentration && actor.client.concentration.city ? actor.client.concentration.city : '',
			conc_state:
				actor.client.concentration && actor.client.concentration.state ? actor.client.concentration.state : '',
			conc_country:
				actor.client.concentration && actor.client.concentration.country ? actor.client.concentration.country : '',
			countries: actor.client.countries || 0,
			location_country: actor.location.country || '',
			risks: actor.risks ? getActorRisks( actor.risks ) : riskTypes.UNKNOWN
		},
...

If it is, an error is thrown.

We haven't actually encountered this problem in real data, but according to Spur's documentation, actor.client is not "required": https://docs.spur.us/#/data-types?id=ip-context-object

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Draft: Avoid error from accessing properties on undefined actor.clientrepos/mediawiki/services/ipoid!220tchandersactor-clientmain
Customize query in GitLab

Event Timeline

I think a similar thing happens for actor.location (e.g. T351405).

dreamyjazz closed https://gitlab.wikimedia.org/repos/mediawiki/services/ipoid/-/merge_requests/220

Draft: Avoid error from accessing properties on undefined actor.client