[GH-ISSUE #41] Fix JSON serialization of Path objects in CodeQLWorkflowResult #7

Closed
opened 2026-03-02 04:07:47 +03:00 by kerem · 1 comment
Owner

Originally created by @gadievron on GitHub (Dec 22, 2025).
Original GitHub issue: https://github.com/gadievron/raptor/issues/41

Problem

Autonomous analysis workflow fails at final step when attempting to serialize CodeQLWorkflowResult to JSON. The to_dict() method uses asdict() which doesn't convert pathlib.Path objects to strings, causing TypeError: Object of type PosixPath is not JSON serializable.

Current incorrect fix: Adding default=str at json.dump() site treats symptom, not cause.

Root Cause

The to_dict() method in CodeQLWorkflowResult (agent.py:46-59) manually converts languages_detected but relies on asdict() for everything else. Python's asdict() doesn't convert non-dataclass types like Path.

Affected Path Objects (4 total)

  1. databases_created[lang].database_path (Optional[Path])
  2. analyses_completed[lang].database_path (Path)
  3. analyses_completed[lang].sarif_path (Optional[Path])
  4. sarif_files (List[Path]) - Type annotation incorrectly claims List[str]

Impact

  • autonomous_summary.json cannot be created
  • Autonomous analysis workflow incomplete
  • All analysis succeeds but final report fails

Fix

Extend to_dict() in CodeQLWorkflowResult to manually convert all Path objects to strings.

File: packages/codeql/agent.py:46-59

Type

  • Bug fix (non-breaking)
  • Bug #3 and Bug #6 from internal analysis (same bug, two investigations)
  • Multi-agent validated: 4/4 validators agree on fix location
  • Multi-LLM validated
Originally created by @gadievron on GitHub (Dec 22, 2025). Original GitHub issue: https://github.com/gadievron/raptor/issues/41 ## Problem Autonomous analysis workflow fails at final step when attempting to serialize `CodeQLWorkflowResult` to JSON. The `to_dict()` method uses `asdict()` which doesn't convert `pathlib.Path` objects to strings, causing `TypeError: Object of type PosixPath is not JSON serializable`. **Current incorrect fix:** Adding `default=str` at json.dump() site treats symptom, not cause. ## Root Cause The `to_dict()` method in `CodeQLWorkflowResult` (agent.py:46-59) manually converts `languages_detected` but relies on `asdict()` for everything else. Python's `asdict()` doesn't convert non-dataclass types like `Path`. ## Affected Path Objects (4 total) 1. `databases_created[lang].database_path` (Optional[Path]) 2. `analyses_completed[lang].database_path` (Path) 3. `analyses_completed[lang].sarif_path` (Optional[Path]) 4. `sarif_files` (List[Path]) - Type annotation incorrectly claims List[str] ## Impact - `autonomous_summary.json` cannot be created - Autonomous analysis workflow incomplete - All analysis succeeds but final report fails ## Fix Extend `to_dict()` in `CodeQLWorkflowResult` to manually convert all Path objects to strings. **File:** `packages/codeql/agent.py:46-59` ## Type - Bug fix (non-breaking) ## Related - Bug #3 and Bug #6 from internal analysis (same bug, two investigations) - Multi-agent validated: 4/4 validators agree on fix location - Multi-LLM validated
kerem 2026-03-02 04:07:47 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@gadievron commented on GitHub (Dec 22, 2025):

Fixed in PR #47

<!-- gh-comment-id:3684217064 --> @gadievron commented on GitHub (Dec 22, 2025): Fixed in PR #47
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/raptor#7
No description provided.