fix(gitea/dev.py): fix CRUD operation bugs for AI agents #7
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/dev-crud-bugs"
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?
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_orgBug: The pattern
user_valves = __user__.get("valves") if __user__ else Noneis 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 bugsBug 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
mergedvariable check logic was inverted - checkedmergedwhen it should checknot mergedfor 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_fileanddelete_file- Inconsistent error handlingBug:
get_response.status_code == 404check was fine, butget_response.raise_for_status()was called after it. The actual issue was the code structure - the check happens but execution continues toraise_for_status()which could throw.Fix: Properly check 404 status and return early before calling
raise_for_status().Version Bump
Pull request closed