Skip to content

Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.

fix(customer-io): validate attribute and message data objects

Rudy Celekli92cf3dfc943f
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index 39ddc4c..68a230d 100644
--- a/.claude-plugin/marketplace.json
+++ b/.claude-plugin/marketplace.json
@@ -6,7 +6,7 @@
},
"metadata": {
"description": "Marketing skills for AI agents — conversion optimization, copywriting, SEO, paid ads, and growth",
- "version": "2.11.26",
+ "version": "2.11.27",
"repository": "https://github.com/coreyhaines31/marketingskills"
},
"plugins": [
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index f1a5cf8..aabe26f 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "marketing-skills",
"description": "Marketing skills for AI agents — conversion optimization, copywriting, SEO, paid ads, ad creative, and growth",
- "version": "2.11.26",
+ "version": "2.11.27",
"author": {
"name": "Corey Haines"
},
diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json
index 45d9d89..9cd1f4c 100644
--- a/.codex-plugin/plugin.json
+++ b/.codex-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "marketing-skills",
"description": "Marketing skills for AI agents — conversion optimization, copywriting, SEO, paid ads, ad creative, and growth",
- "version": "2.11.26",
+ "version": "2.11.27",
"author": {
"name": "Corey Haines"
},
diff --git a/VERSIONS.md b/VERSIONS.md
index dc6d5ce..01c0114 100644
--- a/VERSIONS.md
+++ b/VERSIONS.md
@@ -57,6 +57,10 @@ Current versions of all skills. Agents can compare against local versions to che
## Recent Changes
+### 2.11.27 (2026-10-10)
+
+- Require Customer.io custom attributes, events, and messaging data to be objects.
+
### 2.11.26 (2026-10-08)
- **lead-magnets** (2.0.0 → 2.1.0): new `references/content-to-skill.md` (plus corpus design and release companions) on packaging a course, webinar series, podcast, or newsletter archive you own as an installable agent skill: a new kind of lead magnet. From @rudycelekli's #725 (closes #432), folded in rather than added as a new skill. Triggers added: 'course as a skill,' 'package our content as an agent skill.' **ai-seo** (2.7.5 → 2.7.6) points to it.
diff --git a/tests/clis/customerio-json-data.test.cjs b/tests/clis/customerio-json-data.test.cjs
new file mode 100644
index 0000000..07fe593
--- /dev/null
+++ b/tests/clis/customerio-json-data.test.cjs
@@ -0,0 +1,30 @@
+const { test } = require('node:test')
+const assert = require('node:assert/strict')
+const { spawnSync } = require('node:child_process')
+const path = require('node:path')
+const cli = path.resolve(__dirname, '../../tools/clis/customer-io.js')
+function run(command, flag, value, preview = false) {
+ const args = [...command, flag, value]
+ if (preview) args.push('--dry-run')
+ const source = `global.fetch = async (url, opts) => { process.stderr.write('FETCH_CALLED'); return { status: 200, text: async () => JSON.stringify({ body: JSON.parse(opts.body) }) }; }; process.argv = ['node', ${JSON.stringify(cli)}, ...${JSON.stringify(args)}]; require(${JSON.stringify(cli)});`
+ return spawnSync(process.execPath, ['-e', source], {encoding: 'utf8', env: { ...process.env, CUSTOMERIO_APP_KEY: 'fixture-app', CUSTOMERIO_SITE_ID: 'fixture-site', CUSTOMERIO_API_KEY: 'fixture-track' }, timeout: 5000})
+}
+const commands = [ [['customers', 'identify', 'fixture'], '--data', null], [['customers', 'track-event', 'fixture', '--name', 'Purchased'], '--data', 'data'], [['campaigns', 'trigger', 'fixture', '--ids', 'person'], '--data', 'data'], [['send', 'email', '--message-id', 'fixture', '--to', '[email protected]', '--identifier-id', 'person'], '--data', 'message_data'] ]
+test('event object containers fail before delivery or preview', () => {
+ for (const [command, flag] of commands) for (const value of ['null', '[]', 'true', '42', '"text"']) {
+ for (const preview of [false, true]) {
+ const result = run(command, flag, value, preview)
+ assert.equal(result.status, 1, `${command}: ${value}: ${result.stdout}`)
+ assert.equal(result.stderr.includes('FETCH_CALLED'), false)
+ assert.match(JSON.parse(result.stderr).error, /must be a JSON object/)
+ assert.equal(result.stdout, '')
+ }
+ }
+})
+test('nested event objects and empty dictionaries survive delivery', () => {
+ for (const [command, flag, key] of commands) for (const data of [{}, {customer: {name: 'Zoë'}, items: [1, 2], active: false}]) {
+ const result = run(command, flag, JSON.stringify(data))
+ assert.equal(result.status, 0, result.stderr)
+ assert.deepEqual(key ? JSON.parse(result.stdout).body[key] : JSON.parse(result.stdout).body, data)
+ }
+})
diff --git a/tools/clis/customer-io.js b/tools/clis/customer-io.js
index d00b9c8..864f09e 100755
--- a/tools/clis/customer-io.js
+++ b/tools/clis/customer-io.js
@@ -92,6 +92,14 @@ function parseArgs(args) {
const args = parseArgs(rawArgs)
const [cmd, sub, ...rest] = args._
+function objectData() {
+ const data = JSON.parse(args.data)
+ if (data === null || typeof data !== 'object' || Array.isArray(data)) {
+ throw new Error('--data must be a JSON object')
+ }
+ return data
+}
+
async function main() {
let result
@@ -107,7 +115,7 @@ async function main() {
if (args['last-name']) body.last_name = args['last-name']
if (args['created-at']) body.created_at = parseInt(args['created-at'])
if (args.plan) body.plan = args.plan
- if (args.data) Object.assign(body, JSON.parse(args.data))
+ if (args.data) Object.assign(body, objectData())
result = await trackApi('PUT', `/customers/${encodeURIComponent(customerId)}`, body)
break
}
@@ -135,7 +143,7 @@ async function main() {
if (!customerId) { result = { error: 'Customer ID required (positional arg or --id)' }; break }
if (!args.name) { result = { error: '--name required (event name)' }; break }
const body = { name: args.name }
- if (args.data) body.data = JSON.parse(args.data)
+ if (args.data) body.data = objectData()
result = await trackApi('POST', `/customers/${encodeURIComponent(customerId)}/events`, body)
break
}
@@ -167,7 +175,7 @@ async function main() {
const body = {}
if (args.emails) body.emails = args.emails.split(',')
if (args.ids) body.ids = args.ids.split(',')
- if (args.data) body.data = JSON.parse(args.data)
+ if (args.data) body.data = objectData()
result = await appApi('POST', `/campaigns/${campaignId}/triggers`, body)
break
}
@@ -186,7 +194,7 @@ async function main() {
}
if (args['identifier-id']) body.identifiers.id = args['identifier-id']
if (args['identifier-email']) body.identifiers.email = args['identifier-email']
- if (args.data) body.message_data = JSON.parse(args.data)
+ if (args.data) body.message_data = objectData()
if (args.from) body.from = args.from
if (args.subject) body.subject = args.subject
if (args.body) body.body = args.body