2
20
Fork
You've already forked codeberg-cli
1

cb actions are not compatible with Forgejo Actions response shapes #6

Closed
opened 2026年06月14日 02:54:53 +02:00 by stackdrift · 0 comments
Contributor
Copy link

Summary

Several cb actions commands currently assume GitHub-style Actions response fields or endpoints. On Codeberg/Forgejo, the Actions API returns different shapes, which can make cb actions runs, cb actions run, and cb actions workflows crash instead of displaying results.

Observed failures

Examples observed against Codeberg repositories with Forgejo Actions enabled:

  • cb actions runs --repo stackdrift/esphome-components --limit 1
    • can fail with AttributeError: 'str' object has no attribute 'get'
    • root cause: Forgejo returns an object with workflow_runs, not a raw list
  • cb actions workflows --repo stackdrift-images/grow-app
    • can fail with json.decoder.JSONDecodeError: Extra data
    • root cause: the current workflow-list endpoint/path is not reliable for Codeberg/Forgejo here, and the client assumes error bodies are JSON
  • cb actions run <run-id> --repo <owner/repo>
    • can fail with KeyError: 'display_title'
    • expects GitHub-style fields like display_title, event, head_branch, head_sha, and url
    • Forgejo returns fields like title, trigger_event, prettyref, commit_sha, and html_url

Expected behavior

The actions commands should display runs/workflows normally against Codeberg/Forgejo repositories, and repositories without workflows should print a clean "No workflows" message instead of throwing an exception.

Proposed fix

I have a locally tested branch on my fork: !7

  • normalizes both Forgejo and legacy/GitHub-style action run fields
  • handles Forgejo’s {"workflow_runs": [...], "total_count": ...} response envelope
  • updates cb actions run to display Forgejo run details correctly
  • lists workflows by reading .forgejo/workflows through the repository contents API
  • treats missing workflow directories as "No workflows"
  • makes client error parsing tolerate non-JSON error bodies
  • adds regression tests for the affected action commands and non-JSON error handling

Verification

I ran the following commands to test behavior with my fix:

  • uv run cb actions runs --repo stackdrift/esphome-components --limit 3
  • uv run cb actions run 4740659 --repo stackdrift/esphome-components
  • uv run cb actions workflows --repo stackdrift-images/grow-app
  • uv run cb actions workflows --repo stackdrift/esphome-components
  • uv run cb actions runs --repo stackdrift/starfield-music-tracer --limit 2

I also confirmed the new (and existing) tests passed locally.

## Summary Several `cb actions` commands currently assume GitHub-style Actions response fields or endpoints. On Codeberg/Forgejo, the Actions API returns different shapes, which can make `cb actions runs`, `cb actions run`, and `cb actions workflows` crash instead of displaying results. ## Observed failures Examples observed against Codeberg repositories with Forgejo Actions enabled: - `cb actions runs --repo stackdrift/esphome-components --limit 1` - can fail with `AttributeError: 'str' object has no attribute 'get'` - root cause: Forgejo returns an object with `workflow_runs`, not a raw list - `cb actions workflows --repo stackdrift-images/grow-app` - can fail with `json.decoder.JSONDecodeError: Extra data` - root cause: the current workflow-list endpoint/path is not reliable for Codeberg/Forgejo here, and the client assumes error bodies are JSON - `cb actions run <run-id> --repo <owner/repo>` - can fail with `KeyError: 'display_title'` - expects GitHub-style fields like `display_title`, `event`, `head_branch`, `head_sha`, and `url` - Forgejo returns fields like `title`, `trigger_event`, `prettyref`, `commit_sha`, and `html_url` ## Expected behavior The actions commands should display runs/workflows normally against Codeberg/Forgejo repositories, and repositories without workflows should print a clean "No workflows" message instead of throwing an exception. ## Proposed fix I have a locally tested branch on my fork: !7 - normalizes both Forgejo and legacy/GitHub-style action run fields - handles Forgejo’s `{"workflow_runs": [...], "total_count": ...}` response envelope - updates `cb actions run` to display Forgejo run details correctly - lists workflows by reading `.forgejo/workflows` through the repository contents API - treats missing workflow directories as "No workflows" - makes client error parsing tolerate non-JSON error bodies - adds regression tests for the affected action commands and non-JSON error handling ## Verification I ran the following commands to test behavior with my fix: - `uv run cb actions runs --repo stackdrift/esphome-components --limit 3` - `uv run cb actions run 4740659 --repo stackdrift/esphome-components` - `uv run cb actions workflows --repo stackdrift-images/grow-app` - `uv run cb actions workflows --repo stackdrift/esphome-components` - `uv run cb actions runs --repo stackdrift/starfield-music-tracer --limit 2` I also confirmed the new (and existing) tests passed locally.
Sign in to join this conversation.
No Branch/Tag specified
main
worktree-feature+repo-commands
v0.5.0
v0.4.2
v0.4.1
v0.4.0
v0.2.0
v0.1.0v2
v0.1.0
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
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
thatxliner/codeberg-cli#6
Reference in a new issue
thatxliner/codeberg-cli
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?