Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.
JavaScript agent-skillsai-agentsai-seoclaudeclaude-codeclaude-code-pluginclaude-skillscodexcontent-marketingconversion-rate-optimizationcopywritingcursoremail-marketinggenerative-engine-optimizationgrowth-marketingmarketingmarketing-automationsaas-marketingseoskill-md
fix(sendgrid): reject non-object dynamic template data
Rudy Celekli0b9e47af11dd
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonindex 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.jsonindex 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.jsonindex 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.mdindex dc6d5ce..3ca8f3d 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 SendGrid template data as an object before delivery.+### 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/sendgrid-template-data-object.test.cjs b/tests/clis/sendgrid-template-data-object.test.cjsnew file mode 100644index 0000000..566cae6--- /dev/null+++ b/tests/clis/sendgrid-template-data-object.test.cjs@@ -0,0 +1,29 @@+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/sendgrid.js')+function run(value, preview = false) {+ const args = ['send', '--from', '[email protected]', '--to', '[email protected]', '--template-id', 'd-fixture', '--template-data', 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, SENDGRID_API_KEY: 'fixture' }, timeout: 5000})+}+test('invalid template data containers are rejected before delivery or preview', () => {+ for (const value of ['null', '[]', 'true', '42', '"text"']) {+ for (const preview of [false, true]) {+ const result = run(value, preview)+ assert.equal(result.status, 1, `${value}: ${result.stdout}`)+ assert.equal(result.stderr.includes('FETCH_CALLED'), false)+ assert.match(JSON.parse(result.stderr).error, /template-data must be a JSON object/)+ assert.equal(result.stdout, '')+ }+ }+})+test('nested template data and empty objects are preserved', () => {+ for (const data of [{}, {customer: {name: 'Zoë'}, items: [1, 2], active: false}]) {+ const result = run(JSON.stringify(data))+ assert.equal(result.status, 0, result.stderr)+ assert.deepEqual(JSON.parse(result.stdout).body.personalizations[0].dynamic_template_data, data)+ }+})diff --git a/tools/clis/sendgrid.js b/tools/clis/sendgrid.jsindex 14b7858..bb084d1 100755--- a/tools/clis/sendgrid.js+++ b/tools/clis/sendgrid.js@@ -71,6 +71,10 @@ async function main() {body.template_id = args['template-id']if (args['template-data']) {try { body.personalizations[0].dynamic_template_data = JSON.parse(args['template-data']) } catch (e) { result = { error: 'Invalid JSON for --template-data: ' + e.message }; break }+ const data = body.personalizations[0].dynamic_template_data+ if (data === null || typeof data !== 'object' || Array.isArray(data)) {+ throw new Error('--template-data must be a JSON object')+ }}} else {const content = []