Skip to content

Commit ac29ff8

Browse files
author
TheovanKraay
committed
address review: make the bash composer error reachable under set -e
PR #4389 Copilot review round 8: - bash twin: the script runs under set -euo pipefail, so a nonzero composer status in the _PRESET_BLOCKS assignment aborted immediately and the following exit-code check + diagnostic were unreachable. Put the assignment in an 'if !' condition so set -e does not fire, the intended error is printed, and the update still aborts before any context rewrite. Verified with bash -n.
1 parent 719d319 commit ac29ff8

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

extensions/agent-context/scripts/bash/update-agent-context.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,12 @@ _SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
351351
# Delegated to the python twin's --emit-preset-blocks so all three twins emit
352352
# byte-identical block text from a single implementation. Capture only stdout so
353353
# the composer's warnings (oversized, marker-colliding, or skipped entries) still
354-
# reach stderr, and abort on a nonzero exit so a composer failure never rewrites
355-
# the section with previously composed preset blocks silently dropped.
356-
_PRESET_BLOCKS="$("$_python" "$_SCRIPT_DIR/../python/update_agent_context.py" --emit-preset-blocks --marker-start "$MARKER_START" --marker-end "$MARKER_END")"
357-
_emit_rc=$?
358-
if [[ $_emit_rc -ne 0 ]]; then
359-
echo "agent-context: preset instruction composer failed (exit $_emit_rc); aborting so the managed section is not rewritten with preset blocks dropped." >&2
354+
# reach stderr. The assignment is the condition of an `if` so `set -e` does not
355+
# abort on a nonzero composer status before this diagnostic runs; on failure we
356+
# abort here so a composer failure never rewrites the section with previously
357+
# composed preset blocks silently dropped.
358+
if ! _PRESET_BLOCKS="$("$_python" "$_SCRIPT_DIR/../python/update_agent_context.py" --emit-preset-blocks --marker-start "$MARKER_START" --marker-end "$MARKER_END")"; then
359+
echo "agent-context: preset instruction composer failed; aborting so the managed section is not rewritten with preset blocks dropped." >&2
360360
exit 1
361361
fi
362362

0 commit comments

Comments
 (0)