@@ -14,7 +14,7 @@ import {
1414    type  SessionStateConfig , 
1515    UpdateFilesPathsParams , 
1616}  from  '../../amazonq/commons/types' 
17- import  {  ConversationIdNotFoundError  }  from  '../errors' 
17+ import  {  ContentLengthError ,   ConversationIdNotFoundError  }  from  '../errors' 
1818import  {  featureDevChat ,  referenceLogText ,  featureDevScheme  }  from  '../constants' 
1919import  fs  from  '../../shared/fs/fs' 
2020import  {  FeatureDevClient  }  from  '../client/featureDev' 
@@ -33,6 +33,7 @@ import { UpdateAnswerMessage } from '../../amazonq/commons/connector/connectorMe
3333import  {  FollowUpTypes  }  from  '../../amazonq/commons/types' 
3434import  {  SessionConfig  }  from  '../../amazonq/commons/session/sessionConfigFactory' 
3535import  {  Messenger  }  from  '../../amazonq/commons/connector/baseMessenger' 
36+ import  {  ContentLengthError  as  CommonAmazonQContentLengthError  }  from  '../../amazonq/errors' 
3637export  class  Session  { 
3738    private  _state ?: SessionState  |  Omit < SessionState ,  'uploadId' > 
3839    private  task : string  =  '' 
@@ -137,25 +138,33 @@ export class Session {
137138    } 
138139
139140    private  async  nextInteraction ( msg : string )  { 
140-         const  resp  =  await  this . state . interact ( { 
141-             task : this . task , 
142-             msg, 
143-             fs : this . config . fs , 
144-             messenger : this . messenger , 
145-             telemetry : this . telemetry , 
146-             tokenSource : this . state . tokenSource , 
147-             uploadHistory : this . state . uploadHistory , 
148-         } ) 
141+         try  { 
142+             const  resp  =  await  this . state . interact ( { 
143+                 task : this . task , 
144+                 msg, 
145+                 fs : this . config . fs , 
146+                 messenger : this . messenger , 
147+                 telemetry : this . telemetry , 
148+                 tokenSource : this . state . tokenSource , 
149+                 uploadHistory : this . state . uploadHistory , 
150+             } ) 
149151
150-         if  ( resp . nextState )  { 
151-             if  ( ! this . state ?. tokenSource ?. token . isCancellationRequested )  { 
152-                 this . state ?. tokenSource ?. cancel ( ) 
152+             if  ( resp . nextState )  { 
153+                 if  ( ! this . state ?. tokenSource ?. token . isCancellationRequested )  { 
154+                     this . state ?. tokenSource ?. cancel ( ) 
155+                 } 
156+                 // Move to the next state 
157+                 this . _state  =  resp . nextState 
153158            } 
154-             // Move to the next state 
155-             this . _state  =  resp . nextState 
156-         } 
157159
158-         return  resp . interaction 
160+             return  resp . interaction 
161+         }  catch  ( e )  { 
162+             if  ( e  instanceof  CommonAmazonQContentLengthError )  { 
163+                 getLogger ( ) . debug ( `Content length validation failed: ${ e . message }  ` ) 
164+                 throw  new  ContentLengthError ( ) 
165+             } 
166+             throw  e 
167+         } 
159168    } 
160169
161170    public  async  updateFilesPaths ( params : UpdateFilesPathsParams )  { 
0 commit comments