Page MenuHomePhabricator

efSchemaValidate permits unrecognized additional fields
Closed, ResolvedPublic

Description

If you add additional fields to your event that aren't in the schema+id you specify, efLogServerSideEvent nevertheless logs the event with isValid: true.

In the same situation client-side logEvent() will log with isValid: false and a warning "Unrecognized property: (bogus field's name)".

Depending on how json2sql handles this, the event won't be inserted in the SQL table, or will generate a set of table columns unsuitable for future events.

To reproduce, just add a "boGUSNewKEY" => 666, to a server-side event in PHP.


Version: unspecified
Severity: normal

Details

Reference
bz44454

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:19 AM
bzimport set Reference to bz44454.

This is permitted by the JSON Schema draft v3:

5.4. additionalProperties

This attribute defines a schema for all properties that are not
explicitly defined in an object type definition. If specified, the
value MUST be a schema or a boolean. If false is provided, no
additional properties are allowed beyond the properties defined in
the schema. The default value is an empty schema which allows any
value for additional properties.

http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.4

Nevertheless, this bug is valid, because:

  1. Client-side and server-side validation should behave the same way
  2. A stricter interpretation of the draft in which additional values are disallowed seems sensible.

[moving from MediaWiki extensions to Analytics product - see bug 61946]

In distant hindsight, it might have been nicer to include additional validation for EventLogging schemas, to enforce that the additionalProperties key is present and true for all object elements. That way, the event schema matches the validation that will be performed on payloads.