Skip to content

🎬 Open-source, self-hosted AI agent that runs a YouTube channel end to end: researches topics, writes scripts, generates narration, visuals and video, optimizes SEO, and publishes after your approval, then learns from analytics. Works with Gemini, OpenAI, OpenRouter, DeepSeek and more.

v2.4.1: Fix "topic must be a string" on manual content generation

darkzOGx2a57a1cc03fc
diff --git a/index.js b/index.js
index ca0d3cb..8aafc12 100644
--- a/index.js
+++ b/index.js
@@ -153,7 +153,10 @@ class YouTubeAutomationAgent {
length: typeof body.length === 'string' ? body.length : 'medium'
};
- if (body.topic !== undefined) {
+ // JSON has no `undefined`, so clients send `null` to mean "no value provided".
+ // Both are treated as "not set" here: topic/style are optional and default to
+ // auto-selection, which is exactly what `null` already represents internally.
+ if (body.topic !== undefined && body.topic !== null) {
if (typeof body.topic !== 'string') {
return { valid: false, status: 400, error: 'topic must be a string' };
}
@@ -165,7 +168,7 @@ class YouTubeAutomationAgent {
value.topic = topic || null;
}
- if (body.style !== undefined) {
+ if (body.style !== undefined && body.style !== null) {
if (typeof body.style !== 'string') {
return { valid: false, status: 400, error: 'style must be a string' };
}
diff --git a/package-lock.json b/package-lock.json
index f9ea297..d1d9b1b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "youtube-automation-agent",
- "version": "2.2.0",
+ "version": "2.4.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "youtube-automation-agent",
- "version": "2.2.0",
+ "version": "2.4.1",
"dependencies": {
"@google-cloud/local-auth": "^3.0.0",
"@google/genai": "^2.9.0",
diff --git a/package.json b/package.json
index e63517c..bb5f54b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "youtube-automation-agent",
- "version": "2.4.0",
+ "version": "2.4.1",
"description": "Fully automated YouTube channel management system with specialized AI agents",
"main": "index.js",
"scripts": {
diff --git a/test.js b/test.js
index aeb1da0..ab7515f 100644
--- a/test.js
+++ b/test.js
@@ -171,6 +171,31 @@ class SystemTest {
throw new Error('Non-string topic was not rejected');
}
+ // The dashboard's "Generate Content Now" button sends an explicit null topic
+ // to mean "pick a trending topic for me". null must be accepted, not rejected.
+ const dashboardPayload = agent.validateGenerateRequestBody({ topic: null, style: 'story' });
+ if (!dashboardPayload.valid) {
+ throw new Error(`Dashboard generate payload was rejected: ${dashboardPayload.error}`);
+ }
+ if (dashboardPayload.value.topic !== null || dashboardPayload.value.style !== 'story') {
+ throw new Error('Null topic was not normalised to an auto-selected topic');
+ }
+
+ const nullStyle = agent.validateGenerateRequestBody({ topic: 'Node automation', style: null });
+ if (!nullStyle.valid || nullStyle.value.style !== null) {
+ throw new Error('Null style was not accepted as "no style preference"');
+ }
+
+ const nullLength = agent.validateGenerateRequestBody({ topic: null, style: null, length: null });
+ if (!nullLength.valid || nullLength.value.length !== 'medium') {
+ throw new Error('Null length did not fall back to the default length');
+ }
+
+ const blankTopic = agent.validateGenerateRequestBody({ topic: ' ' });
+ if (!blankTopic.valid || blankTopic.value.topic !== null) {
+ throw new Error('Whitespace-only topic was not normalised to null');
+ }
+
const invalidStyle = agent.validateGenerateRequestBody({ style: 'x'.repeat(51) });
if (invalidStyle.valid || invalidStyle.status !== 400) {
throw new Error('Overlong style was not rejected');