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

fix: preserve blank vision and safe upload inputs (#4922)

[._.]/ Adam Eivy519ea78672f9
diff --git a/server/lib/validation.js b/server/lib/validation.js
index ca4c4e178e..e78ec3c700 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -513,10 +513,10 @@ export const providerSchema = z.object({
export const providerVisionTestSchema = z.object({
imagePath: z.string().trim().min(1).max(255),
prompt: z.string().max(8_000).optional(),
- expectedContent: z.union([
+ expectedContent: z.preprocess(emptyToUndefined, z.union([
z.string().trim().min(1).max(128),
z.array(z.string().trim().min(1).max(128)).max(50),
- ]).optional(),
+ ]).optional()),
model: z.preprocess(emptyToUndefined, z.string().trim().min(1).max(256).optional()),
});
@@ -530,7 +530,8 @@ export const providerVisionSuiteSchema = z.object({
// the JSON shape before the helper receives it.
export const base64FileUploadSchema = z.object({
data: z.string().trim().min(1, 'data is required (base64)').max(64 * 1024 * 1024),
- filename: z.string().min(1, 'filename is required').max(255),
+ // The upload helper prefixes the sanitized name with a 9-byte UUID marker.
+ filename: z.string().min(1, 'filename is required').max(246),
});
export const uploadRequestSchema = base64FileUploadSchema;
diff --git a/server/lib/validation.test.js b/server/lib/validation.test.js
index 908bff9c74..041a2e8ca0 100644
--- a/server/lib/validation.test.js
+++ b/server/lib/validation.test.js
@@ -101,6 +101,14 @@ describe('validation.js', () => {
serviceName: 'example-service',
fromTime: '',
}).fromTime).toBeUndefined();
+ expect(providerVisionTestSchema.parse({
+ imagePath: 'example.png',
+ expectedContent: '',
+ }).expectedContent).toBeUndefined();
+ expect(uploadRequestSchema.safeParse({
+ data: 'aGVsbG8=',
+ filename: `${'a'.repeat(247)}.txt`,
+ }).success).toBe(false);
});
it('rejects malformed upload and vision request bodies', () => {