Skip to content

Comments

t1185: Fix AI Actions Pipeline 'expected array, got empty' parsing error#1802

Closed
marcusquinn wants to merge 1 commit intomainfrom
feature/t1185
Closed

t1185: Fix AI Actions Pipeline 'expected array, got empty' parsing error#1802
marcusquinn wants to merge 1 commit intomainfrom
feature/t1185

Conversation

@marcusquinn
Copy link
Owner

Fix AI Actions Pipeline 'expected array, got empty' parsing error.

Changes

  • ai-actions.sh: Add whitespace-only response check (catches responses that are all whitespace but not empty string)
  • ai-actions.sh: Add ANSI-strip recovery in array type check — if jq 'type' fails on the action plan, strip ANSI escape codes and retry before giving up
  • ai-actions.sh: Enhance debug logging with hex dump of first 32 bytes for future parse failure diagnosis

Root Cause

The error 'expected array, got ' (empty plan_type) occurs when jq 'type' fails on the action plan returned by run_ai_reasoning. This happens when:

  1. Two concurrent pulse runs bypass the lock file race window
  2. Both call the AI CLI (opencode with --format default)
  3. The response contains ANSI escape codes that corrupt JSON parsing
  4. extract_action_plan fails all parse attempts and returns empty
  5. run_ai_reasoning returns rc=1 with error object — but in some cases ANSI-contaminated content slips through

The ai-reason.sh already has ANSI stripping (t1182). This PR adds a second layer of defence in run_ai_actions_pipeline itself.

Fixes

  1. Strip markdown code fences: Already handled by extract_action_plan (Try 2-5 in ai-reason.sh, t1182)
  2. Handle empty/whitespace-only responses: Added whitespace-trimmed check in pipeline + already in ai-reason.sh (t1182)
  3. Log raw AI response on parse failure: Enhanced with hex dump for binary/ANSI diagnosis

Ref #1793

- Add whitespace-only check before empty check in run_ai_actions_pipeline
  to catch responses that are all whitespace but not empty string
- Add ANSI-strip recovery in array type check: if jq 'type' fails on
  action_plan, strip ANSI codes and retry before giving up — recovers
  arrays that were contaminated by opencode --format default output
- Enhance debug logging: add hex dump of first 32 bytes alongside
  head/len to diagnose future parse failures (t1182/t1185)

The ai-reason.sh already has ANSI stripping (t1182) but the pipeline
adds a second layer of defence in case any ANSI codes slip through.
Root cause: concurrent pulse runs can bypass the lock file race window,
both call opencode, and the deployed version lacked ANSI stripping.
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 37 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t1185

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 26 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Wed Feb 18 21:41:36 UTC 2026: Code review monitoring started
Wed Feb 18 21:41:37 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 26

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 26
  • VULNERABILITIES: 0

Generated on: Wed Feb 18 21:41:39 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@marcusquinn
Copy link
Owner Author

Closing as duplicate of #1797 (t1184). Both fix the same 'expected array' parsing bug. #1797 is more comprehensive (covers both ai-actions.sh and ai-reason.sh with whitespace handling, type-checking, indented bracket matching, and full raw response logging).

@marcusquinn marcusquinn deleted the feature/t1185 branch February 21, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant