MCPcopy Create free account
hub / github.com/github/gh-aw / processCloseEntityItems

Function processCloseEntityItems

actions/setup/js/close_entity_helpers.cjs:464–594  ·  view source on GitHub ↗

* Process close entity items from agent output * @param {EntityConfig} config - Entity configuration * @param {EntityCallbacks} callbacks - Entity-specific API callbacks * @param {Object} handlerConfig - Handler-specific configuration object * @returns {Promise<Array<{entity: {number: number, ht

(config, callbacks, handlerConfig = {})

Source from the content-addressed store, hash-verified

462 * @returns {Promise<Array<{entity: {number: number, html_url: string, title: string}, comment: {id: number, html_url: string}}>|undefined>}
463 */
464async function processCloseEntityItems(config, callbacks, handlerConfig = {}) {
465 // Check if we're in staged mode
466 const isStaged = isStagedMode(handlerConfig);
467
468 const result = loadAgentOutput();
469 if (!result.success) {
470 return;
471 }
472
473 // Find all items of this type
474 const items = result.items.filter(/** @param {any} item */ item => item.type === config.itemType);
475 if (items.length === 0) {
476 core.info(`No ${config.itemTypeDisplay} items found in agent output`);
477 return;
478 }
479
480 core.info(`Found ${items.length} ${config.itemTypeDisplay} item(s)`);
481
482 // Get configuration from handlerConfig object (not environment variables)
483 const requiredLabels = handlerConfig.required_labels || [];
484 const requiredTitlePrefix = handlerConfig.required_title_prefix || "";
485 const target = handlerConfig.target || "triggering";
486
487 core.info(`Configuration: requiredLabels=${requiredLabels.join(",")}, requiredTitlePrefix=${requiredTitlePrefix}, target=${target}`);
488
489 // Check if we're in the correct entity context
490 const isEntityContext = config.contextEvents.some(event => context.eventName === event);
491
492 // If in staged mode, emit step summary instead of closing entities
493 if (isStaged) {
494 await generateCloseEntityStagedPreview(config, items, requiredLabels, requiredTitlePrefix);
495 return;
496 }
497
498 // Validate context based on target configuration
499 if (target === "triggering" && !isEntityContext) {
500 core.info(`Target is "triggering" but not running in ${config.displayName} context, skipping ${config.displayName} close`);
501 return;
502 }
503
504 // Extract triggering context for footer generation
505 const triggeringIssueNumber = context.payload?.issue?.number;
506 const triggeringPRNumber = context.payload?.pull_request?.number;
507
508 const closedEntities = [];
509
510 // Process each item
511 for (let i = 0; i < items.length; i++) {
512 const item = items[i];
513 core.info(`Processing ${config.itemTypeDisplay} item ${i + 1}/${items.length}: bodyLength=${item.body.length}`);
514
515 // Resolve entity number
516 const resolved = resolveEntityNumber(config, target, item, isEntityContext);
517 if (!resolved.success) {
518 core.info(resolved.message);
519 continue;
520 }
521 const entityNumber = resolved.number;

Callers

nothing calls this directly

Calls 11

isStagedModeFunction · 0.85
loadAgentOutputFunction · 0.85
resolveEntityNumberFunction · 0.85
checkLabelFilterFunction · 0.85
checkTitlePrefixFilterFunction · 0.85
sanitizeContentFunction · 0.85
escapeMarkdownTitleFunction · 0.85
errorMethod · 0.80
buildCommentBodyFunction · 0.70
getErrorMessageFunction · 0.70

Tested by

no test coverage detected