@@ -269,6 +269,7 @@ function createCloseEntityHandler(config, entityConfig, callbacks, githubClient)
269269 const comment = config . comment || "" ;
270270 const isStaged = isStagedMode ( config ) ;
271271 const { defaultTargetRepo, allowedRepos } = resolveTargetRepoConfig ( config ) ;
272+ const allowBody = config . allow_body !== false ; // default true; false only when explicitly set to false
272273
273274 let processedCount = 0 ;
274275
@@ -293,12 +294,22 @@ function createCloseEntityHandler(config, entityConfig, callbacks, githubClient)
293294 core . info ( `Processing ${ entityConfig . itemType } message: ${ JSON . stringify ( logFields ) } ` ) ;
294295
295296 // 2. Comment body resolution
296- /** @type {string } */
297+ /** @type {string|undefined } */
297298 let commentToPost ;
298299 /** @type {string } */
299300 let commentSource = "unknown" ;
300301
301- if ( typeof item . body === "string" && item . body . trim ( ) !== "" ) {
302+ if ( ! allowBody ) {
303+ // allow-body: false — drop any body the agent provided and skip the comment
304+ if ( typeof item . body === "string" && item . body . trim ( ) !== "" ) {
305+ core . warning (
306+ `${ entityConfig . itemType } : allow-body is false — dropping non-empty body (length=${ item . body . length } ) and closing without a comment`
307+ ) ;
308+ } else {
309+ core . info ( `${ entityConfig . itemType } : allow-body is false — closing without a comment` ) ;
310+ }
311+ commentToPost = undefined ;
312+ } else if ( typeof item . body === "string" && item . body . trim ( ) !== "" ) {
302313 commentToPost = item . body ;
303314 commentSource = "item.body" ;
304315 } else if ( typeof comment === "string" && comment . trim ( ) !== "" ) {
@@ -309,10 +320,12 @@ function createCloseEntityHandler(config, entityConfig, callbacks, githubClient)
309320 return { success : false , error : "No comment body provided" } ;
310321 }
311322
312- core . info ( `Comment body determined: length=${ commentToPost . length } , source=${ commentSource } ` ) ;
323+ if ( commentToPost !== undefined ) {
324+ core . info ( `Comment body determined: length=${ commentToPost . length } , source=${ commentSource } ` ) ;
313325
314- // 3. Content sanitization
315- commentToPost = sanitizeContent ( commentToPost ) ;
326+ // 3. Content sanitization
327+ commentToPost = sanitizeContent ( commentToPost ) ;
328+ }
316329
317330 // 4. Target repository / entity number resolution
318331 const targetResult = callbacks . resolveTarget ( item , config , resolvedTemporaryIds ) ;
@@ -379,34 +392,38 @@ function createCloseEntityHandler(config, entityConfig, callbacks, githubClient)
379392 } ;
380393 }
381394
382- // 9. Comment posting
383- const commentBody = callbacks . buildCommentBody ( commentToPost , item ) ;
384- core . info ( `Adding comment to ${ entityConfig . displayName } #${ entityNumber } : length=${ commentBody . length } ` ) ;
385-
395+ // 9. Comment posting (skipped when allow-body: false or no body available)
386396 /** @type {{id: number, html_url: string}|null } */
387397 let commentResult = null ;
388398 let commentPosted = false ;
389- try {
390- commentResult = await callbacks . addComment ( githubClient , owner , repoName , entityNumber , commentBody ) ;
391- commentPosted = true ;
392- core . info ( `✓ Comment posted to ${ entityConfig . displayName } #${ entityNumber } : ${ commentResult . html_url } ` ) ;
393- core . info ( `Comment details: id=${ commentResult . id } , body_length=${ commentBody . length } ` ) ;
394- } catch ( commentError ) {
395- const errorMsg = getErrorMessage ( commentError ) ;
396- if ( callbacks . continueOnCommentError ) {
397- core . error ( `Failed to add comment to ${ entityConfig . displayName } #${ entityNumber } : ${ errorMsg } ` ) ;
398- core . error (
399- `Error details: ${ JSON . stringify ( {
400- entityNumber,
401- hasBody : ! ! item . body ,
402- bodyLength : item . body ? item . body . length : 0 ,
403- errorMessage : errorMsg ,
404- } ) } `
405- ) ;
406- // commentPosted stays false; close operation continues
407- } else {
408- throw new Error ( `${ ERR_API } : Failed to add comment to ${ entityConfig . displayName } #${ entityNumber } : ${ errorMsg } ` , { cause : commentError } ) ;
399+ if ( commentToPost !== undefined ) {
400+ const commentBody = callbacks . buildCommentBody ( commentToPost , item ) ;
401+ core . info ( `Adding comment to ${ entityConfig . displayName } #${ entityNumber } : length=${ commentBody . length } ` ) ;
402+
403+ try {
404+ commentResult = await callbacks . addComment ( githubClient , owner , repoName , entityNumber , commentBody ) ;
405+ commentPosted = true ;
406+ core . info ( `✓ Comment posted to ${ entityConfig . displayName } #${ entityNumber } : ${ commentResult . html_url } ` ) ;
407+ core . info ( `Comment details: id=${ commentResult . id } , body_length=${ commentBody . length } ` ) ;
408+ } catch ( commentError ) {
409+ const errorMsg = getErrorMessage ( commentError ) ;
410+ if ( callbacks . continueOnCommentError ) {
411+ core . error ( `Failed to add comment to ${ entityConfig . displayName } #${ entityNumber } : ${ errorMsg } ` ) ;
412+ core . error (
413+ `Error details: ${ JSON . stringify ( {
414+ entityNumber,
415+ hasBody : ! ! item . body ,
416+ bodyLength : item . body ? item . body . length : 0 ,
417+ errorMessage : errorMsg ,
418+ } ) } `
419+ ) ;
420+ // commentPosted stays false; close operation continues
421+ } else {
422+ throw new Error ( `${ ERR_API } : Failed to add comment to ${ entityConfig . displayName } #${ entityNumber } : ${ errorMsg } ` , { cause : commentError } ) ;
423+ }
409424 }
425+ } else {
426+ core . info ( `Skipping comment for ${ entityConfig . displayName } #${ entityNumber } : no comment body` ) ;
410427 }
411428
412429 // 10. Entity close (skipped when already closed)
0 commit comments