Snowplow home
Products
Solutions
Integrations Customers
Resources
Pricing Log in

Insights 3 min read

JSON Schema additionalProperties: default, true vs false

In JSON Schema, additionalProperties allows extra fields by default. See what true and false do, the pros and cons, and how Snowplow loads extra fields.

In JSON Schema, additionalProperties allows extra fields by default. Leave it out, and any property your schema doesn't declare still passes validation (JSON Schema reference).

Snowplow's own example schemas set it to false. So for Snowplow users, the real question is what happens to extra fields if you set it to true.

The answer depends on your warehouse. This post covers the default, true vs false with an example, the pros and cons, and how Snowplow loads (or drops) fields your schema doesn't declare.

What does additionalProperties do?

additionalProperties controls whether an object can carry properties that aren't listed under properties in its schema.

  • Left out: extra properties are allowed.
  • true: the same as leaving it out. Extra properties are allowed.
  • false: any property the schema doesn't list fails validation.

Snowplow schemas are based on JSON Schema draft 4 and live in Iglu, Snowplow's schema repository. Every event is validated against its schema, and events that fail go to failed events instead of your warehouse.

additionalProperties true vs false: an example

Here's a schema for a button click event. It declares two fields and sets additionalProperties to false:

{
  "$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
  "description": "A click on a call-to-action button",
  "self": {
    "vendor": "com.acme",
    "name": "button_click",
    "format": "jsonschema",
    "version": "1-0-0"
  },
  "type": "object",
  "properties": {
    "label": { "type": "string", "maxLength": 100 },
    "page": { "type": "string", "maxLength": 255 }
  },
  "required": ["label"],
  "additionalProperties": false
}

Now the tracking sends a field the schema doesn't know about, variant:

{
  "schema": "iglu:com.acme/button_click/jsonschema/1-0-0",
  "data": {
    "label": "Book a demo",
    "page": "/pricing",
    "variant": "B"
  }
}
  • With "additionalProperties": false, the event fails validation and lands in failed events. Nothing from it reaches the warehouse until the tracking or the schema is fixed.
  • With "additionalProperties": true (or the line left out), the event passes. label and page load as normal. What happens to variant depends on your warehouse.

What happens to extra fields in the warehouse?

Snowplow's loaders handle undeclared fields differently by warehouse (schema translation docs):

  • Redshift, BigQuery, Databricks, Iceberg and Delta Lake: fields not defined in the schema are not stored.
  • Synapse Analytics: fields not defined in the schema are not stored in the data lake and aren't available in Synapse.
  • Snowflake: fields not defined in the schema are included in the event's object column. They only get that far if additionalProperties is true, because otherwise the event fails validation.

So on most warehouses, true keeps the event but loses the extra field. On Snowflake, you keep both.

additionalProperties true vs false: pros and cons

Setting Pros Cons
true (or left out) Events with new or unexpected fields still pass validation. Tracking can send a field before the schema lists it. On most warehouses the extra fields are dropped, so you can't analyze them. A misspelled field name passes without warning. The schema no longer describes everything the event carries.
false A field the schema doesn't declare fails the event, so tracking mistakes show up in failed events. The schema describes the event completely, which is what a data contract needs. Every new field needs a new schema version. Old app versions that send an extra field keep producing failed events until they're updated.

For that last case, Snowplow lets a new schema version supersede an old one, so events sent against the old version are validated against the new one.

Which should you use?

Snowplow's example schemas use false, and it's the safer default for production tracking. A few guidelines:

  • Use true sparingly. Keep it for schemas whose shape changes often, and only where losing the extra fields is acceptable, or where you load to Snowflake and plan to read them there.
  • Declare the flexible part. If some data really is dynamic, give it a declared object or array field instead of allowing any property at the top level. Making Snowplow schemas flexible covers the approach.
  • Promote fields that stick. When an extra field becomes permanent, add it to the schema as a new version. Adding an optional field is a non-breaking change, for example 1-0-0 to 1-0-1 (versioning docs). See SchemaVer for how Snowplow numbers versions.
  • Watch failed events. With false, failed events are where tracking drift shows up first. What is bad data explains how to manage it.

Frequently asked questions

What is the default value of additionalProperties in JSON Schema?

By default, JSON Schema allows additional properties. If a schema leaves out additionalProperties, an object can include properties the schema doesn't declare and still pass validation.

What does additionalProperties: false do?

It rejects any property that isn't listed under properties. In Snowplow, an event or entity carrying an undeclared field fails validation and goes to failed events instead of the warehouse.

Should I set additionalProperties to true or false?

For most Snowplow schemas, use false. It catches tracking mistakes and keeps the schema a complete description of the data. Use true only where the shape changes often and you can accept that most warehouses drop the extra fields.

What happens to extra properties in Snowplow events when they reach the warehouse?

It depends on the warehouse. Redshift, BigQuery, Databricks, Iceberg, Delta Lake and Synapse don't store fields the schema doesn't define. Snowflake keeps them in the event's object column, as long as additionalProperties is true so the event passes validation.

Subscribe to our newsletter

Get the latest content to your inbox monthly.

See Snowplow on your own use case.

Book a demo built around what you want to build.