Skip to content

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

fix(kit): validate custom field dictionaries before mutations

Rudy Celekli67182f366e19
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..c7d3285 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)
+
+- Validate Kit custom field dictionaries before subscriber mutations.
+
### 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/kit-field-objects.test.cjs b/tests/clis/kit-field-objects.test.cjs
new file mode 100644
index 0000000..717aed2
--- /dev/null
+++ b/tests/clis/kit-field-objects.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/kit.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, KIT_API_KEY: 'fixture-key', KIT_API_SECRET: 'fixture-secret' }, timeout: 5000})
+}
+const commands = [ [['subscribers', 'update', '123'], '--fields'], ...['forms', 'sequences', 'tags'].map(cmd => [[cmd, 'subscribe', '123', '--email', '[email protected]'], '--fields']) ]
+test('custom field 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 field objects and empty dictionaries survive delivery', () => {
+ for (const [command, flag] 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(JSON.parse(result.stdout).body[flag.slice(2)], data)
+ }
+})
diff --git a/tools/clis/kit.js b/tools/clis/kit.js
index f1d1565..388fcec 100755
--- a/tools/clis/kit.js
+++ b/tools/clis/kit.js
@@ -84,6 +84,13 @@ function parseArgs(args) {
const args = parseArgs(rawArgs)
const [cmd, sub, ...rest] = args._
+function requireFieldObject(fields) {
+ if (fields === null || typeof fields !== 'object' || Array.isArray(fields)) {
+ throw new Error('--fields must be a JSON object')
+ }
+ return fields
+}
+
async function main() {
let result
@@ -105,6 +112,7 @@ async function main() {
if (args['first-name']) body.first_name = args['first-name']
if (args.fields) {
try { body.fields = JSON.parse(args.fields) } catch { result = { error: 'Invalid JSON in --fields' }; break }
+ requireFieldObject(body.fields)
}
result = await api('PUT', `/subscribers/${rest[0]}`, body)
break
@@ -132,6 +140,7 @@ async function main() {
if (args['first-name']) body.first_name = args['first-name']
if (args.fields) {
try { body.fields = JSON.parse(args.fields) } catch { result = { error: 'Invalid JSON in --fields' }; break }
+ requireFieldObject(body.fields)
}
result = await api('POST', `/forms/${formId}/subscribe`, body, false)
break
@@ -154,6 +163,7 @@ async function main() {
if (args['first-name']) body.first_name = args['first-name']
if (args.fields) {
try { body.fields = JSON.parse(args.fields) } catch { result = { error: 'Invalid JSON in --fields' }; break }
+ requireFieldObject(body.fields)
}
result = await api('POST', `/sequences/${sequenceId}/subscribe`, body, false)
break
@@ -176,6 +186,7 @@ async function main() {
if (args['first-name']) body.first_name = args['first-name']
if (args.fields) {
try { body.fields = JSON.parse(args.fields) } catch { result = { error: 'Invalid JSON in --fields' }; break }
+ requireFieldObject(body.fields)
}
result = await api('POST', `/tags/${tagId}/subscribe`, body, false)
break