fix: cap orchestration task link token length (#6246)
This commit is contained in:
parent
6574e764d7
commit
d33c5260fd
|
|
@ -160,6 +160,15 @@ describe('extractOrchestrationTaskLinks', () => {
|
|||
{ taskId: 'task_worker', startIndex: 5, endIndex: 16 }
|
||||
])
|
||||
})
|
||||
|
||||
it('caps orchestration task IDs by full token length', () => {
|
||||
const maxLengthTaskId = `task_${'a'.repeat(123)}`
|
||||
|
||||
expect(extractOrchestrationTaskLinks(`Open ${maxLengthTaskId}`)).toEqual([
|
||||
{ taskId: maxLengthTaskId, startIndex: 5, endIndex: 133 }
|
||||
])
|
||||
expect(extractOrchestrationTaskLinks(`Open task_${'a'.repeat(124)}`)).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('findTerminalHandleTarget', () => {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export type ParsedOrchestrationTaskLink = {
|
|||
|
||||
export const ORCHESTRATION_TASK_PREFIX = 'task_'
|
||||
|
||||
const MAX_ORCHESTRATION_TASK_BODY_LENGTH = 128
|
||||
const MAX_ORCHESTRATION_TASK_TOKEN_LENGTH = 128
|
||||
const ORCHESTRATION_TASK_BOUNDARY_CHAR = /[A-Za-z0-9_-]/
|
||||
|
||||
export function extractOrchestrationTaskLinks(lineText: string): ParsedOrchestrationTaskLink[] {
|
||||
|
|
@ -28,11 +28,14 @@ export function extractOrchestrationTaskLinks(lineText: string): ParsedOrchestra
|
|||
const tokenEnd = findOrchestrationTaskTokenEnd(lineText, bodyStart)
|
||||
searchStart = Math.max(tokenEnd, bodyStart + 1)
|
||||
const bodyLength = tokenEnd - bodyStart
|
||||
if (bodyLength === 0 || bodyLength > MAX_ORCHESTRATION_TASK_BODY_LENGTH) {
|
||||
if (bodyLength === 0) {
|
||||
continue
|
||||
}
|
||||
|
||||
const taskId = lineText.slice(startIndex, tokenEnd)
|
||||
if (taskId.length > MAX_ORCHESTRATION_TASK_TOKEN_LENGTH) {
|
||||
continue
|
||||
}
|
||||
if (
|
||||
ORCHESTRATION_TASK_BOUNDARY_CHAR.test(lineText[startIndex - 1] ?? '') ||
|
||||
ORCHESTRATION_TASK_BOUNDARY_CHAR.test(lineText[tokenEnd] ?? '')
|
||||
|
|
|
|||
Loading…
Reference in New Issue