Skip to content

Commit 3446374

Browse files
committed
Fix JSON escaping in aicode-preprocess workflow
- Use jq to properly construct JSON payload instead of manual sed escaping - Prevents errors with quotes and special characters in task descriptions - Fixes 'command not found' and 'malformed JSON' errors
1 parent 2d9ed90 commit 3446374

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

.github/workflows/aicode-preprocess.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,32 @@ jobs:
6262
ORIGINAL_TASK="${{ github.event.client_payload.task }}"
6363
6464
# Escape JSON special characters in task strings
65-
ENHANCED_TASK_ESCAPED=$(echo "$ENHANCED_TASK" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
65+
# Use jq to properly construct JSON payload with proper escaping
66+
PAYLOAD=$(jq -n \
67+
--arg event_type "aicode-enhanced" \
68+
--arg task "$ENHANCED_TASK" \
69+
--arg original_task "$ORIGINAL_TASK" \
70+
--arg requester "$REQUESTER" \
71+
--arg channel "$CHANNEL" \
72+
--arg timestamp "$TIMESTAMP" \
73+
--arg preprocessing_run_id "$RUN_ID" \
74+
'{
75+
event_type: $event_type,
76+
client_payload: {
77+
task: $task,
78+
original_task: $original_task,
79+
requester: $requester,
80+
channel: $channel,
81+
timestamp: $timestamp,
82+
preprocessing_run_id: $preprocessing_run_id
83+
}
84+
}')
85+
86+
curl -X POST "https://api.github.com/repos/${{ github.repository }}/dispatches" \
87+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
88+
-H "Accept: application/vnd.github+json" \
89+
-H "Content-Type: application/json" \
90+
-d "$PAYLOAD" 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
6691
ORIGINAL_TASK_ESCAPED=$(echo "$ORIGINAL_TASK" | sed 's/"/\\"/g')
6792
6893
curl -X POST "https://api.github.com/repos/${{ github.repository }}/dispatches" \

0 commit comments

Comments
 (0)