A developer asks Copilot CLI to generate a local repair script for a failing integration test. The script will be used before assigning the issue to Copilot coding agent again. Which change should you make first? Select one answer.
#!/usr/bin/env bash
set -e
copilot
# Prompt:
# Fix the failing integration setup.
# If a command fails, keep enough output for a reviewer
# and do not continue with destructive cleanup.
Copilot proposes this script:
#!/usr/bin/env bash
rm -rf test-output
mkdir test-output
npm ci
npm run integration
rm -rf docker-data
git add .
git commit -m "agent: repair integration setup"Choose an answer
Tap an option to check your answer.
Correct answer: Add explicit failure traps and logging.
Why this is the answer
The correct answer is to add explicit failure traps and logging. The prompt explicitly states, "If a command fails, keep enough output for a reviewer and do not continue with destructive cleanup." The proposed script lacks any error handling or logging mechanisms. Adding set -e at the beginning is a good start, but more robust error traps (e.g., trap 'echo "Error: Command failed at line $LINENO" &2; exit 1' ERR) and logging of command outputs are necessary to meet the prompt's requirements for reviewability and preventing destructive cleanup on failure. Adding git push after the commit is premature; the script's primary goal is to repair the setup, not push changes immediately. Ignoring cleanup until review finishes is not practical; the prompt specifically asks to avoid destructive cleanup if a command fails, implying cleanup might be necessary otherwise. Running the script from any trusted directory is a general security practice but doesn't address the specific requirements for error handling and logging within the script itself.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed