@@ -58,10 +58,11 @@ export class CfnAI implements SettingsConfigurable, Closeable {
5858 throw new Error ( `Template not found ${ toString ( templateFile ) } ` ) ;
5959 }
6060
61- return await agent . execute (
62- await Prompts . describeTemplate ( document . contents ( ) ) ,
63- await this . getToolsWithFallback ( ) ,
64- ) ;
61+ const content = document . contents ( ) ;
62+ if ( ! content ) {
63+ throw new Error ( 'Document content is undefined' ) ;
64+ }
65+ return await agent . execute ( await Prompts . describeTemplate ( content ) , await this . getToolsWithFallback ( ) ) ;
6566 } ) ;
6667 }
6768
@@ -72,10 +73,11 @@ export class CfnAI implements SettingsConfigurable, Closeable {
7273 throw new Error ( `Template not found ${ toString ( templateFile ) } ` ) ;
7374 }
7475
75- return await agent . execute (
76- await Prompts . optimizeTemplate ( document . contents ( ) ) ,
77- await this . getToolsWithFallback ( ) ,
78- ) ;
76+ const content = document . contents ( ) ;
77+ if ( ! content ) {
78+ throw new Error ( 'Document content is undefined' ) ;
79+ }
80+ return await agent . execute ( await Prompts . optimizeTemplate ( content ) , await this . getToolsWithFallback ( ) ) ;
7981 } ) ;
8082 }
8183
@@ -86,8 +88,12 @@ export class CfnAI implements SettingsConfigurable, Closeable {
8688 return ;
8789 }
8890
91+ const content = document . contents ( ) ;
92+ if ( ! content ) {
93+ throw new Error ( 'Document content is undefined' ) ;
94+ }
8995 return await agent . execute (
90- await Prompts . analyzeDiagnostic ( document . contents ( ) , diagnostics ) ,
96+ await Prompts . analyzeDiagnostic ( content , diagnostics ) ,
9197 await this . getToolsWithFallback ( ) ,
9298 ) ;
9399 } ) ;
@@ -107,6 +113,9 @@ export class CfnAI implements SettingsConfigurable, Closeable {
107113 }
108114
109115 const templateContent = document . contents ( ) ;
116+ if ( ! templateContent ) {
117+ throw new Error ( 'Document content is undefined' ) ;
118+ }
110119
111120 const resourceTypes = this . relationshipSchemaService . extractResourceTypesFromTemplate ( templateContent ) ;
112121 const relationshipContext = this . relationshipSchemaService . getRelationshipContext ( resourceTypes ) ;
0 commit comments