From e891c5ba83ca9a53a55f64d9213ffd6d5253d6ca Mon Sep 17 00:00:00 2001 From: james-haytko_nwx Date: Tue, 24 Feb 2026 10:42:12 -0600 Subject: [PATCH] Script now handles the dict-wrapper case --- .../claude-documentation-reviewer.yml | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/claude-documentation-reviewer.yml b/.github/workflows/claude-documentation-reviewer.yml index c6817661f7..de5f5049e4 100644 --- a/.github/workflows/claude-documentation-reviewer.yml +++ b/.github/workflows/claude-documentation-reviewer.yml @@ -112,11 +112,27 @@ jobs: try: with open('/tmp/suggestions.json') as f: - suggestions = json.load(f) + data = json.load(f) except (FileNotFoundError, json.JSONDecodeError) as e: print(f"Could not read /tmp/suggestions.json: {e}") sys.exit(1) + # Handle case where Claude wraps the array in an object + if isinstance(data, dict): + for key in data: + if isinstance(data[key], list): + data = data[key] + break + else: + print(f"Unexpected dict structure: {list(data.keys())}") + sys.exit(1) + + if not isinstance(data, list): + print(f"Expected array, got {type(data)}") + sys.exit(1) + + suggestions = data + if not suggestions: subprocess.run( ['gh', 'pr', 'comment', pr_number, '--repo', repo, @@ -128,6 +144,9 @@ jobs: comments = [] for s in suggestions: + if not isinstance(s, dict): + print(f"Skipping non-object suggestion: {repr(s)[:100]}") + continue body = s['body'] + '\n```suggestion\n' + s['suggestion'] + '\n```' c = {'path': s['path'], 'line': s['line'], 'side': 'RIGHT', 'body': body} if s.get('start_line') and s['start_line'] != s['line']: @@ -135,6 +154,10 @@ jobs: c['start_side'] = 'RIGHT' comments.append(c) + if not comments: + print("No valid suggestions to post") + sys.exit(1) + review_data = { 'commit_id': head_sha, 'body': f'Found {len(comments)} issue(s). To apply all fixes at once, reply with `@claude` followed by your instructions (e.g. `@claude fix all issues`).',