Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

Default a missing prompt to empty so i2i submits don't 400

[._.]/ Adam Eivyf8d5391f4370
diff --git a/server/routes/imageGen.js b/server/routes/imageGen.js
index 83ee090b2c..51af44e201 100644
--- a/server/routes/imageGen.js
+++ b/server/routes/imageGen.js
@@ -52,8 +52,10 @@ const router = Router();
router.get('/style-presets', (_req, res) => res.json(STYLE_PRESETS));
const generateSchema = z.object({
- // Empty prompt allowed — i2i / edit / unconditional generation don't require one.
- prompt: z.string().max(8000),
+ // Empty prompt allowed — i2i / edit / unconditional generation don't require
+ // one. The multipart FormData builder drops empty-string fields, so an empty
+ // prompt arrives as `undefined`; default it to '' rather than rejecting.
+ prompt: z.string().max(8000).optional().default(''),
negativePrompt: z.string().max(8000).optional(),
// Per-request backend override. If omitted, the dispatcher uses
// `imageGen.mode` from settings.json.
diff --git a/server/routes/imageGen.test.js b/server/routes/imageGen.test.js
index 4da199d8ed..3f2ad13ad1 100644
--- a/server/routes/imageGen.test.js
+++ b/server/routes/imageGen.test.js
@@ -160,13 +160,18 @@ describe('Image Gen Routes', () => {
expect(imageGen.generateImage).toHaveBeenCalledWith(expect.objectContaining({ prompt: 'a fantasy landscape' }));
});
- it('should return 400 if prompt is missing', async () => {
+ it('accepts a missing/empty prompt (i2i / edit / unconditional), defaulting it to empty', async () => {
+ imageGen.generateImage.mockResolvedValue({
+ generationId: 'gen-empty',
+ filename: 'test.png',
+ path: '/data/images/test.png'
+ });
const response = await request(app)
.post('/api/image-gen/generate')
.send({});
- expect(response.status).toBe(400);
- expect(imageGen.generateImage).not.toHaveBeenCalled();
+ expect(response.status).toBe(200);
+ expect(imageGen.generateImage).toHaveBeenCalledWith(expect.objectContaining({ prompt: '' }));
});
it('should validate width and height bounds', async () => {