diff --git a/packages/@n8n/syslog-client/src/schemas.ts b/packages/@n8n/syslog-client/src/schemas.ts index ef0c8e0ead8..64a1f2e23ce 100644 --- a/packages/@n8n/syslog-client/src/schemas.ts +++ b/packages/@n8n/syslog-client/src/schemas.ts @@ -42,7 +42,7 @@ export const logOptionsSchema = z.object({ appName: z.string().max(48).optional(), syslogHostname: z.string().optional(), timestamp: z.instanceof(Date).optional(), - msgid: z.string().optional(), + msgid: z.string().max(32).optional(), // RFC 5424 limit }); /** diff --git a/packages/@n8n/syslog-client/test/formats.test.ts b/packages/@n8n/syslog-client/test/formats.test.ts index 25d7fcee644..9e745a0cb27 100644 --- a/packages/@n8n/syslog-client/test/formats.test.ts +++ b/packages/@n8n/syslog-client/test/formats.test.ts @@ -138,6 +138,45 @@ describe('SyslogClient - Message Formats', () => { client.close(); }); + it('should accept msgid up to 32 characters (RFC 5424 limit)', async () => { + const hostname = 'testhostname'; + const client = new SyslogClient('127.0.0.1', { + port: SYSLOG_UDP_PORT, + syslogHostname: hostname, + transport: Transport.Udp, + }); + + const maxLengthMsgid = '550e8400e29b41d4a716446655440000'; // 32 chars (UUID without hyphens) + await client.log('Max length msgid', { + rfc3164: false, + msgid: maxLengthMsgid, + }); + + const msg = await awaitUdpMsg(); + expect(msg).toMatch(constructRfc5424Regex(134, hostname, 'Max length msgid', maxLengthMsgid)); + + client.close(); + }); + + it('should reject msgid longer than 32 characters (RFC 5424 limit)', async () => { + const hostname = 'testhostname'; + const client = new SyslogClient('127.0.0.1', { + port: SYSLOG_UDP_PORT, + syslogHostname: hostname, + transport: Transport.Udp, + }); + + const tooLongMsgid = '550e8400-e29b-41d4-a716-446655440000'; // 36 chars (UUID with hyphens) + await expect( + client.log('Too long msgid', { + rfc3164: false, + msgid: tooLongMsgid, + }), + ).rejects.toThrow(); + + client.close(); + }); + it('should send back-dated RFC 5424 messages', async () => { const hostname = 'testhostname'; const client = new SyslogClient('127.0.0.1', { diff --git a/packages/cli/src/modules/log-streaming.ee/destinations/message-event-bus-destination-syslog.ee.ts b/packages/cli/src/modules/log-streaming.ee/destinations/message-event-bus-destination-syslog.ee.ts index c56416ab485..6db5fd8222c 100644 --- a/packages/cli/src/modules/log-streaming.ee/destinations/message-event-bus-destination-syslog.ee.ts +++ b/packages/cli/src/modules/log-streaming.ee/destinations/message-event-bus-destination-syslog.ee.ts @@ -95,7 +95,7 @@ export class MessageEventBusDestinationSyslog JSON.stringify(serializedMessage), { severity: msg.eventName.toLowerCase().endsWith('error') ? Severity.Error : Severity.Debug, - msgid: msg.id, + msgid: msg.id.length > 32 ? msg.id.replace(/-/g, '').substring(0, 32) : msg.id, timestamp: msg.ts.toJSDate(), }, async (error) => {