Preferences Stored as JSON, Secrets Encrypted
Author: damianlegawiecCreated Oct 1, 2026Updated Oct 1, 2026
Every model's preferences column is a YAML document. Spree 6.0 moves them to a JSON column (jsonb on PostgreSQL, json on MySQL and SQLite), and moves secrets into a separate encrypted column. The way preferences are declared does not change.
Why:
- Gateway and integration secrets (preferences declared
:password) are stored in plain text today. - Loading YAML is an attack surface that Rails has to restrict with a list of permitted classes, which Spree injects into every application.
- Two tables added in 6.0 (delivery method rules, commission rules) are typed JSON but actually hold a YAML document wrapped in a JSON string.
- Being able to query preferences is a side benefit only.
What changes:
- One JSON coder replaces YAML for every preferences column. Values come back as the same Ruby types as before, cast through each preference's declared type. Decimals are stored as exact strings.
:passwordpreferences are stored in asecret_preferencescolumn using Rails' standard encryption.preference :secret_key, :passwordandpreferred_secret_keykeep working unchanged.- Encryption applies whenever encryption keys are configured, as for Spree's other encrypted fields. New projects have keys from setup.
- One migration converts existing data and moves existing secrets across. They stay readable immediately, and an upgrade task encrypts them.
- A row that still holds YAML raises a clear error naming the fix.
- The tiered promotion calculators store their tiers as a list of
{threshold, value}objects instead of a hash with number keys. This changes how these calculators'tiersappear in the Admin API.
Plan: https://github.com/spree/spree/blob/main/docs/plans/6.0-json-preferences.md
Tracked in Linear as V-3730
Source: spree/spree