fix(gitea/dev.py): fix CRUD operation bugs for AI agents #7

Closed
xcaliber wants to merge 0 commits from fix/dev-crud-bugs into main
Owner

Summary

Fixed critical bugs in the Gitea dev.py CRUD operations for AI agents.

Bugs Fixed

1. Redundant __user__ checks (Multiple methods)

Affected: _get_token, _get_repo, _get_branch, _get_org

Bug: The pattern user_valves = __user__.get("valves") if __user__ else None is redundant because we already checked __user__ before entering the block.

Fix: Simplified to user_valves = __user__.get("valves") followed by a check for truthiness.

2. merge_pull_request - Multiple critical bugs

Bug 1: response.raise_for_status() was called AFTER checking for 405, but before the check, so 405 would throw an exception before being handled.

Bug 2: Missing conflict detection for HTTP 409 (merge conflicts).

Bug 3: The merged variable check logic was inverted - checked merged when it should check not merged for failure case.

Bug 4: Empty response handling didn't account for HTTP 200 with empty body.

Fix: Restructured to check 409 and 405 status codes BEFORE raise_for_status(), and fixed the merged status check logic.

3. update_file and delete_file - Inconsistent error handling

Bug: get_response.status_code == 404 check was fine, but get_response.raise_for_status() was called after it. The actual issue was the code structure - the check happens but execution continues to raise_for_status() which could throw.

Fix: Properly check 404 status and return early before calling raise_for_status().

Version Bump

  • Updated version from 1.4.0 to 1.4.1 with changelog entry
## Summary Fixed critical bugs in the Gitea dev.py CRUD operations for AI agents. ## Bugs Fixed ### 1. Redundant `__user__` checks (Multiple methods) **Affected:** `_get_token`, `_get_repo`, `_get_branch`, `_get_org` **Bug:** The pattern `user_valves = __user__.get("valves") if __user__ else None` is redundant because we already checked `__user__` before entering the block. **Fix:** Simplified to `user_valves = __user__.get("valves")` followed by a check for truthiness. ### 2. `merge_pull_request` - Multiple critical bugs **Bug 1:** `response.raise_for_status()` was called AFTER checking for 405, but before the check, so 405 would throw an exception before being handled. **Bug 2:** Missing conflict detection for HTTP 409 (merge conflicts). **Bug 3:** The `merged` variable check logic was inverted - checked `merged` when it should check `not merged` for failure case. **Bug 4:** Empty response handling didn't account for HTTP 200 with empty body. **Fix:** Restructured to check 409 and 405 status codes BEFORE `raise_for_status()`, and fixed the merged status check logic. ### 3. `update_file` and `delete_file` - Inconsistent error handling **Bug:** `get_response.status_code == 404` check was fine, but `get_response.raise_for_status()` was called after it. The actual issue was the code structure - the check happens but execution continues to `raise_for_status()` which could throw. **Fix:** Properly check 404 status and return early before calling `raise_for_status()`. ## Version Bump - Updated version from 1.4.0 to 1.4.1 with changelog entry
xcaliber closed this pull request 2026-01-17 10:25:29 +00:00

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: open-webui-automation/tools#7
No description provided.