Skip to content

Commit df0a6f9

Browse files
committed
Fix shell quoting issue: Use JSON output instead of direct variable expansion
- Read enhanced task from JSON output using jq to avoid shell parsing issues - Prevents 'command not found' errors when task contains quotes - JSON is properly escaped and safe to parse
1 parent 2ac4ed5 commit df0a6f9

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

.github/workflows/aicode-preprocess.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,26 @@ jobs:
7171
- name: Trigger main agent workflow
7272
if: always()
7373
run: |
74+
# Read enhanced task from JSON output to avoid shell quoting issues
75+
TASK_JSON="${{ steps.preprocess.outputs.task_json }}"
76+
77+
if [ -n "$TASK_JSON" ] && [ "$TASK_JSON" != "null" ]; then
78+
# Extract values from JSON using jq (handles all escaping automatically)
79+
ENHANCED_TASK=$(echo "$TASK_JSON" | jq -r '.enhanced // empty')
80+
ORIGINAL_TASK=$(echo "$TASK_JSON" | jq -r '.original // empty')
81+
CONFLUENCE_URL=$(echo "$TASK_JSON" | jq -r '.confluenceUrl // "N/A"')
82+
else
83+
# Fallback to outputs if JSON not available
7484
ENHANCED_TASK="${{ steps.preprocess.outputs.enhanced_task }}"
7585
ORIGINAL_TASK="${{ github.event.client_payload.task }}"
86+
CONFLUENCE_URL="${{ steps.preprocess.outputs.confluence_url }}"
87+
fi
88+
89+
# Use GitHub Actions context for other values (these are safe)
7690
REQUESTER="${{ github.event.client_payload.requester }}"
7791
CHANNEL="${{ github.event.client_payload.channel }}"
7892
TIMESTAMP="${{ github.event.client_payload.timestamp }}"
7993
RUN_ID="${{ github.run_id }}"
80-
CONFLUENCE_URL="${{ steps.preprocess.outputs.confluence_url }}"
8194
8295
# Use jq to properly construct JSON payload with proper escaping
8396
PAYLOAD=$(jq -n \
@@ -107,3 +120,18 @@ jobs:
107120
-H "Accept: application/vnd.github+json" \
108121
-H "Content-Type: application/json" \
109122
-d "$PAYLOAD"
123+
124+
- name: Notify Slack on preprocessing completion
125+
if: always()
126+
run: |
127+
if [ "${{ steps.preprocess.outcome }}" == "success" ]; then
128+
curl -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
129+
-H "Content-Type: application/json" \
130+
-d "{\"text\":\"📝 Task preprocessed and enhanced. Triggering code generation...\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"📝 *Task Preprocessing Complete*\\n\\n*Original:* ${{ github.event.client_payload.task }}\\n\\n*Enhanced:* ${{ steps.preprocess.outputs.enhanced_task }}\"}}]}"
131+
else
132+
curl -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
133+
-H "Content-Type: application/json" \
134+
-d "{\"text\":\"⚠️ Preprocessing failed, using original task\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"⚠️ *Preprocessing Warning*\\n\\nPreprocessing failed, but code generation will continue with original task.\"}}]}"
135+
fi
136+
env:
137+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)