mirror of
https://github.com/stablyai/orca.git
synced 2026-09-29 00:02:56 +00:00
fix(native-chat): reject noncanonical stored conversation names
This commit is contained in:
@@ -33,6 +33,18 @@ describe('agent session record conversationName validation', () => {
|
||||
false
|
||||
)
|
||||
})
|
||||
|
||||
it('rejects persisted names that bypassed canonical normalization', () => {
|
||||
expect(
|
||||
isAgentSessionRecord({
|
||||
...agentSessionRecordFixture(),
|
||||
conversationName: 'Fix\u202Egnp.exe probe'
|
||||
})
|
||||
).toBe(false)
|
||||
expect(
|
||||
isAgentSessionRecord({ ...agentSessionRecordFixture(), conversationName: 'Fix\nthe probe' })
|
||||
).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('setAgentSessionRecordConversationName', () => {
|
||||
|
||||
@@ -38,10 +38,13 @@ describe('normalizeAgentSessionConversationName', () => {
|
||||
})
|
||||
|
||||
describe('isAgentSessionConversationName', () => {
|
||||
it('accepts a bounded non-empty string and nothing else', () => {
|
||||
it('accepts only bounded canonical names', () => {
|
||||
expect(isAgentSessionConversationName('Fix the probe')).toBe(true)
|
||||
expect(isAgentSessionConversationName('')).toBe(false)
|
||||
expect(isAgentSessionConversationName('a'.repeat(201))).toBe(false)
|
||||
expect(isAgentSessionConversationName(' Fix the probe ')).toBe(false)
|
||||
expect(isAgentSessionConversationName('Fix\nthe probe')).toBe(false)
|
||||
expect(isAgentSessionConversationName('Fix\u202Egnp.exe probe')).toBe(false)
|
||||
expect(isAgentSessionConversationName(7)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -61,6 +61,7 @@ export function isAgentSessionConversationName(value: unknown): value is string
|
||||
return (
|
||||
typeof value === 'string' &&
|
||||
value.length > 0 &&
|
||||
value.length <= AGENT_SESSION_CONVERSATION_NAME_MAX_LENGTH
|
||||
value.length <= AGENT_SESSION_CONVERSATION_NAME_MAX_LENGTH &&
|
||||
normalizeAgentSessionConversationName(value) === value
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user