Skip to content

fix(pr): handle JSON array timeline payload in _parse_timeline_copilot_state #245

Description

@dan-petty

Bug Description

When gh api --paginate repos/{owner}/{repo}/issues/{pr}/timeline --jq ... returns a JSON array (such as empty array [] when no copilot timeline events match), _parse_timeline_copilot_state attempts to call evt.get('event') on the parsed list object, raising:
AttributeError: 'list' object has no attribute 'get'

Stack Trace

  File "/workspaces/devops-cli/src/devops_cli/github/pr_monitor.py", line 258, in _parse_timeline_copilot_state
    evt_name = evt.get("event")
AttributeError: 'list' object has no attribute 'get'

Proposed Remediation

Support both list and dict structures in _parse_timeline_copilot_state, safely handling top-level arrays, NDJSON, and empty lists. Add unit tests covering list payloads.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingscope/githubGitHub Projects v2, Views, Milestones, Labels, and PR automation

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions