Skip to content

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

fix(onesignal): validate audience payload shapes and filter limits (#832)

Rudy Mizrahi Celekliad937028c95d
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index 396a387..9f7f3c0 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.37",
+ "version": "2.11.38",
"repository": "https://github.com/coreyhaines31/marketingskills"
},
"plugins": [
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index 177ed04..16b7c51 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.37",
+ "version": "2.11.38",
"author": {
"name": "Corey Haines"
},
diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json
index 60d1f5c..dadb149 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.37",
+ "version": "2.11.38",
"author": {
"name": "Corey Haines"
},
diff --git a/VERSIONS.md b/VERSIONS.md
index 5e7dbdf..b813e8c 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.38 (2026-10-15)
+
+- Validate OneSignal segment filter object arrays with the documented 200-entry limit, while preserving JSON alias dictionaries and comma-separated external IDs, including numeric-looking IDs.
+
### 2.11.37 (2026-10-15)
Copywriting and ads now read the learnings ledger added to product-marketing in 2.11.34.
diff --git a/tests/clis/onesignal-audience-shapes.test.cjs b/tests/clis/onesignal-audience-shapes.test.cjs
new file mode 100644
index 0000000..7ba109a
--- /dev/null
+++ b/tests/clis/onesignal-audience-shapes.test.cjs
@@ -0,0 +1,34 @@
+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/onesignal.js')
+function run(kind,value,preview=false){
+ const args=kind==='filters'?['segments','create','--name','Fixture']:['notifications','send','--message','Fixture'];if(value!==undefined)args.push(`--${kind}`,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),headers:opts.headers})}};process.argv=['node',${JSON.stringify(cli)},...${JSON.stringify(args)}];require(${JSON.stringify(cli)})`
+ return spawnSync(process.execPath,['-e',source],{encoding:'utf8',env:{...process.env,ONESIGNAL_REST_API_KEY:'fixture-key',ONESIGNAL_APP_ID:'fixture-app'},timeout:5000})
+}
+test('preserves JSON-scalar-looking external IDs in delivery and preview',()=>{
+ for(const value of ['12345','null','[]','true','42','"text"'])for(const preview of [false,true]){
+ const r=run('aliases',value,preview);assert.equal(r.status,0,r.stderr);assert.deepEqual(JSON.parse(r.stdout).body.include_aliases,{external_id:[value]});assert.equal(r.stderr.includes('FETCH_CALLED'),!preview)
+ }
+})
+test('rejects invalid segment filter arrays and counts before requests',()=>{
+ for(const value of ['null','{}','true','42','"text"','[]','[null]','[[]]','[42]',JSON.stringify(Array(201).fill({field:'session_count',relation:'>',value:'0'}))])for(const preview of [false,true]){
+ const r=run('filters',value,preview);assert.equal(r.status,1,r.stdout);assert.equal(r.stderr.includes('FETCH_CALLED'),false);assert.match(JSON.parse(r.stderr).error,/array of 1–200 filter or operator objects/)
+ }
+})
+test('preserves alias dictionaries and comma-separated shorthand',()=>{
+ for(const preview of [false,true])for(const value of ['{"external_id":["user1"],"custom_alias":["user2"]}','user1,user2']){
+ const r=run('aliases',value,preview);assert.equal(r.status,0,r.stderr);assert.deepEqual(JSON.parse(r.stdout).body.include_aliases,value[0]==='{'?JSON.parse(value):{external_id:['user1','user2']})
+ }
+})
+test('preserves default filters, operators and 200-entry boundary',()=>{
+ const filter={field:'session_count',relation:'>',value:'0'}
+ for(const preview of [false,true])for(const value of [undefined,JSON.stringify([filter,{operator:'OR'},{field:'tag',key:'level',relation:'=',value:'10'}]),JSON.stringify(Array(200).fill(filter))]){
+ const r=run('filters',value,preview);assert.equal(r.status,0,r.stderr);assert.deepEqual(JSON.parse(r.stdout).body.filters,value===undefined?[filter]:JSON.parse(value))
+ }
+})
+test('preserves malformed segment-filter parse diagnostic',()=>{
+ const r=run('filters','{broken');assert.equal(r.stderr.includes('FETCH_CALLED'),false);assert.equal(JSON.parse(r.stdout).error,'Invalid JSON in --filters')
+})
diff --git a/tools/clis/onesignal.js b/tools/clis/onesignal.js
index ffe4731..3af462f 100755
--- a/tools/clis/onesignal.js
+++ b/tools/clis/onesignal.js
@@ -116,6 +116,9 @@ async function main() {
} catch {
payload.include_aliases = { external_id: args.aliases.split(',') }
}
+ if (!payload.include_aliases || typeof payload.include_aliases !== 'object' || Array.isArray(payload.include_aliases)) {
+ payload.include_aliases = { external_id: args.aliases.split(',') }
+ }
} else {
payload.included_segments = ['Subscribed Users']
}
@@ -156,6 +159,10 @@ async function main() {
if (!name) { result = { error: '--name required' }; break }
let filters
try { filters = args.filters ? JSON.parse(args.filters) : [{ field: 'session_count', relation: '>', value: '0' }] } catch { result = { error: 'Invalid JSON in --filters' }; break }
+ if (!Array.isArray(filters) || filters.length < 1 || filters.length > 200 ||
+ filters.some(filter => !filter || typeof filter !== 'object' || Array.isArray(filter))) {
+ throw new Error('--filters must be an array of 1–200 filter or operator objects')
+ }
result = await api('POST', `/api/v1/apps/${APP_ID}/segments`, { name, filters })
break
}