***v36 #36

Merged
gitea merged 2 commits from mitch into develop 2026-07-09 19:44:25 +00:00
Owner
No description provided.
gitea added 2 commits 2026-07-09 19:20:58 +00:00
V36
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_metadata/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
63e288d5f0
Author
Owner

🤖 drep AI Code Review

The PR extracts inline Python from the CI config into a well-structured standalone script (ci/add-ai-reviewed-label.py). This is a positive change for maintainability. The new script follows good practices: type hints, error handling, environment variable validation, timeouts, and clear constants. However, there are a few type safety concerns where the code assumes specific response types (dict vs list) from the generic api_request function. Adding runtime type checks or narrowing the return type per endpoint would improve robustness. The index.php change is just a version bump. Overall, a solid improvement with minor type-safety warnings to address.

Recommendation: Approve

Concerns:

  • Type assumptions in api_request return values could cause runtime errors if Gitea API behavior changes

Generated by drep using nvidia/nemotron-3-ultra-550b-a55b:free

## 🤖 drep AI Code Review The PR extracts inline Python from the CI config into a well-structured standalone script (`ci/add-ai-reviewed-label.py`). This is a positive change for maintainability. The new script follows good practices: type hints, error handling, environment variable validation, timeouts, and clear constants. However, there are a few type safety concerns where the code assumes specific response types (dict vs list) from the generic `api_request` function. Adding runtime type checks or narrowing the return type per endpoint would improve robustness. The `index.php` change is just a version bump. Overall, a solid improvement with minor type-safety warnings to address. **Recommendation:** ✅ Approve **Concerns:** - Type assumptions in api_request return values could cause runtime errors if Gitea API behavior changes --- *Generated by drep using nvidia/nemotron-3-ultra-550b-a55b:free*
gitea reviewed 2026-07-09 19:21:13 +00:00
gitea left a comment
Author
Owner

Inline review comment generated by drep.

Inline review comment generated by drep.
@ -0,0 +27,4 @@
body = None
if data is not None:
headers["Content-Type"] = "application/json"
body = json.dumps(data).encode()
Author
Owner

💡 SUGGESTION: The return type dict | list is too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint.

Suggested fix:

def api_request(token: str, method: str, url: str, data: dict | None = None) -> dict:
    # Note: Gitea API returns dict for single objects, list for collections.
    # This function assumes dict response; callers expecting list should handle accordingly.
💡 **SUGGESTION**: The return type `dict | list` is too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint. **Suggested fix:** ```python def api_request(token: str, method: str, url: str, data: dict | None = None) -> dict: # Note: Gitea API returns dict for single objects, list for collections. # This function assumes dict response; callers expecting list should handle accordingly. ```
@ -0,0 +47,4 @@
token = require_env("GITEA_TOKEN")
owner = require_env("CI_REPO_OWNER")
repo = require_env("CI_REPO_NAME")
pr = require_env("CI_COMMIT_PULL_REQUEST")
Author
Owner

⚠️ WARNING: The issue variable is assumed to be a dict, but api_request can return a list. If the API returns a list (unlikely for /issues/{pr} but possible on error), this will fail with AttributeError.

Suggested fix:

issue = api_request(token, "GET", f"{base}/issues/{pr}")
if not isinstance(issue, dict):
    print(f"ERROR: Unexpected response type for issue: {type(issue)}", file=sys.stderr)
    sys.exit(1)
⚠️ **WARNING**: The `issue` variable is assumed to be a dict, but `api_request` can return a list. If the API returns a list (unlikely for `/issues/{pr}` but possible on error), this will fail with AttributeError. **Suggested fix:** ```python issue = api_request(token, "GET", f"{base}/issues/{pr}") if not isinstance(issue, dict): print(f"ERROR: Unexpected response type for issue: {type(issue)}", file=sys.stderr) sys.exit(1) ```
@ -0,0 +51,4 @@
base = f"{GITEA_URL}/api/v1/repos/{owner}/{repo}"
issue = api_request(token, "GET", f"{base}/issues/{pr}")
labels_on_pr = issue.get("labels", [])
Author
Owner

⚠️ WARNING: Same issue here - repo_labels is assumed to be a list but api_request returns dict | list. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail.

Suggested fix:

repo_labels = api_request(token, "GET", f"{base}/labels")
if not isinstance(repo_labels, list):
    print(f"ERROR: Expected list for repo labels, got {type(repo_labels)}", file=sys.stderr)
    sys.exit(1)
⚠️ **WARNING**: Same issue here - `repo_labels` is assumed to be a list but `api_request` returns `dict | list`. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail. **Suggested fix:** ```python repo_labels = api_request(token, "GET", f"{base}/labels") if not isinstance(repo_labels, list): print(f"ERROR: Expected list for repo labels, got {type(repo_labels)}", file=sys.stderr) sys.exit(1) ```
@ -0,0 +59,4 @@
repo_labels = api_request(token, "GET", f"{base}/labels")
label_id = next(
(label["id"] for label in repo_labels if label.get("name") == LABEL_NAME),
None,
Author
Owner

💡 SUGGESTION: The created variable assumes the response is a dict with an 'id' key. Add validation for robustness.

Suggested fix:

created = api_request(
    token,
    "POST",
    f"{base}/labels",
    {
        "name": LABEL_NAME,
        "color": "0e8a16",
        "description": "Drep AI review completed by Woodpecker",
    },
)
if not isinstance(created, dict) or "id" not in created:
    print(f"ERROR: Unexpected response when creating label: {created}", file=sys.stderr)
    sys.exit(1)
label_id = created["id"]
💡 **SUGGESTION**: The `created` variable assumes the response is a dict with an 'id' key. Add validation for robustness. **Suggested fix:** ```python created = api_request( token, "POST", f"{base}/labels", { "name": LABEL_NAME, "color": "0e8a16", "description": "Drep AI review completed by Woodpecker", }, ) if not isinstance(created, dict) or "id" not in created: print(f"ERROR: Unexpected response when creating label: {created}", file=sys.stderr) sys.exit(1) label_id = created["id"] ```
@ -0,0 +65,4 @@
created = api_request(
token,
"POST",
f"{base}/labels",
Author
Owner

ℹ️ INFO: Consider adding a success exit code explicitly for clarity, though sys.exit(0) is implicit.

Suggested fix:

print(f"Added label {LABEL_NAME!r} to PR #{pr}")
    sys.exit(0)
ℹ️ **INFO**: Consider adding a success exit code explicitly for clarity, though `sys.exit(0)` is implicit. **Suggested fix:** ```python print(f"Added label {LABEL_NAME!r} to PR #{pr}") sys.exit(0) ```
gitea reviewed 2026-07-09 19:21:13 +00:00
gitea left a comment
Author
Owner

Inline review comment generated by drep.

Inline review comment generated by drep.
@ -0,0 +27,4 @@
body = None
if data is not None:
headers["Content-Type"] = "application/json"
body = json.dumps(data).encode()
Author
Owner

💡 SUGGESTION: The return type dict | list is too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint.

Suggested fix:

def api_request(token: str, method: str, url: str, data: dict | None = None) -> dict:
    # Note: Gitea API returns dict for single objects, list for collections.
    # This function assumes dict response; callers expecting list should handle accordingly.
💡 **SUGGESTION**: The return type `dict | list` is too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint. **Suggested fix:** ```python def api_request(token: str, method: str, url: str, data: dict | None = None) -> dict: # Note: Gitea API returns dict for single objects, list for collections. # This function assumes dict response; callers expecting list should handle accordingly. ```
@ -0,0 +47,4 @@
token = require_env("GITEA_TOKEN")
owner = require_env("CI_REPO_OWNER")
repo = require_env("CI_REPO_NAME")
pr = require_env("CI_COMMIT_PULL_REQUEST")
Author
Owner

⚠️ WARNING: The issue variable is assumed to be a dict, but api_request can return a list. If the API returns a list (unlikely for /issues/{pr} but possible on error), this will fail with AttributeError.

Suggested fix:

issue = api_request(token, "GET", f"{base}/issues/{pr}")
if not isinstance(issue, dict):
    print(f"ERROR: Unexpected response type for issue: {type(issue)}", file=sys.stderr)
    sys.exit(1)
⚠️ **WARNING**: The `issue` variable is assumed to be a dict, but `api_request` can return a list. If the API returns a list (unlikely for `/issues/{pr}` but possible on error), this will fail with AttributeError. **Suggested fix:** ```python issue = api_request(token, "GET", f"{base}/issues/{pr}") if not isinstance(issue, dict): print(f"ERROR: Unexpected response type for issue: {type(issue)}", file=sys.stderr) sys.exit(1) ```
@ -0,0 +51,4 @@
base = f"{GITEA_URL}/api/v1/repos/{owner}/{repo}"
issue = api_request(token, "GET", f"{base}/issues/{pr}")
labels_on_pr = issue.get("labels", [])
Author
Owner

⚠️ WARNING: Same issue here - repo_labels is assumed to be a list but api_request returns dict | list. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail.

Suggested fix:

repo_labels = api_request(token, "GET", f"{base}/labels")
if not isinstance(repo_labels, list):
    print(f"ERROR: Expected list for repo labels, got {type(repo_labels)}", file=sys.stderr)
    sys.exit(1)
⚠️ **WARNING**: Same issue here - `repo_labels` is assumed to be a list but `api_request` returns `dict | list`. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail. **Suggested fix:** ```python repo_labels = api_request(token, "GET", f"{base}/labels") if not isinstance(repo_labels, list): print(f"ERROR: Expected list for repo labels, got {type(repo_labels)}", file=sys.stderr) sys.exit(1) ```
@ -0,0 +59,4 @@
repo_labels = api_request(token, "GET", f"{base}/labels")
label_id = next(
(label["id"] for label in repo_labels if label.get("name") == LABEL_NAME),
None,
Author
Owner

💡 SUGGESTION: The created variable assumes the response is a dict with an 'id' key. Add validation for robustness.

Suggested fix:

created = api_request(
    token,
    "POST",
    f"{base}/labels",
    {
        "name": LABEL_NAME,
        "color": "0e8a16",
        "description": "Drep AI review completed by Woodpecker",
    },
)
if not isinstance(created, dict) or "id" not in created:
    print(f"ERROR: Unexpected response when creating label: {created}", file=sys.stderr)
    sys.exit(1)
label_id = created["id"]
💡 **SUGGESTION**: The `created` variable assumes the response is a dict with an 'id' key. Add validation for robustness. **Suggested fix:** ```python created = api_request( token, "POST", f"{base}/labels", { "name": LABEL_NAME, "color": "0e8a16", "description": "Drep AI review completed by Woodpecker", }, ) if not isinstance(created, dict) or "id" not in created: print(f"ERROR: Unexpected response when creating label: {created}", file=sys.stderr) sys.exit(1) label_id = created["id"] ```
@ -0,0 +65,4 @@
created = api_request(
token,
"POST",
f"{base}/labels",
Author
Owner

ℹ️ INFO: Consider adding a success exit code explicitly for clarity, though sys.exit(0) is implicit.

Suggested fix:

print(f"Added label {LABEL_NAME!r} to PR #{pr}")
    sys.exit(0)
ℹ️ **INFO**: Consider adding a success exit code explicitly for clarity, though `sys.exit(0)` is implicit. **Suggested fix:** ```python print(f"Added label {LABEL_NAME!r} to PR #{pr}") sys.exit(0) ```
gitea reviewed 2026-07-09 19:21:13 +00:00
gitea left a comment
Author
Owner

Inline review comment generated by drep.

Inline review comment generated by drep.
@ -0,0 +27,4 @@
body = None
if data is not None:
headers["Content-Type"] = "application/json"
body = json.dumps(data).encode()
Author
Owner

💡 SUGGESTION: The return type dict | list is too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint.

Suggested fix:

def api_request(token: str, method: str, url: str, data: dict | None = None) -> dict:
    # Note: Gitea API returns dict for single objects, list for collections.
    # This function assumes dict response; callers expecting list should handle accordingly.
💡 **SUGGESTION**: The return type `dict | list` is too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint. **Suggested fix:** ```python def api_request(token: str, method: str, url: str, data: dict | None = None) -> dict: # Note: Gitea API returns dict for single objects, list for collections. # This function assumes dict response; callers expecting list should handle accordingly. ```
@ -0,0 +47,4 @@
token = require_env("GITEA_TOKEN")
owner = require_env("CI_REPO_OWNER")
repo = require_env("CI_REPO_NAME")
pr = require_env("CI_COMMIT_PULL_REQUEST")
Author
Owner

⚠️ WARNING: The issue variable is assumed to be a dict, but api_request can return a list. If the API returns a list (unlikely for /issues/{pr} but possible on error), this will fail with AttributeError.

Suggested fix:

issue = api_request(token, "GET", f"{base}/issues/{pr}")
if not isinstance(issue, dict):
    print(f"ERROR: Unexpected response type for issue: {type(issue)}", file=sys.stderr)
    sys.exit(1)
⚠️ **WARNING**: The `issue` variable is assumed to be a dict, but `api_request` can return a list. If the API returns a list (unlikely for `/issues/{pr}` but possible on error), this will fail with AttributeError. **Suggested fix:** ```python issue = api_request(token, "GET", f"{base}/issues/{pr}") if not isinstance(issue, dict): print(f"ERROR: Unexpected response type for issue: {type(issue)}", file=sys.stderr) sys.exit(1) ```
@ -0,0 +51,4 @@
base = f"{GITEA_URL}/api/v1/repos/{owner}/{repo}"
issue = api_request(token, "GET", f"{base}/issues/{pr}")
labels_on_pr = issue.get("labels", [])
Author
Owner

⚠️ WARNING: Same issue here - repo_labels is assumed to be a list but api_request returns dict | list. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail.

Suggested fix:

repo_labels = api_request(token, "GET", f"{base}/labels")
if not isinstance(repo_labels, list):
    print(f"ERROR: Expected list for repo labels, got {type(repo_labels)}", file=sys.stderr)
    sys.exit(1)
⚠️ **WARNING**: Same issue here - `repo_labels` is assumed to be a list but `api_request` returns `dict | list`. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail. **Suggested fix:** ```python repo_labels = api_request(token, "GET", f"{base}/labels") if not isinstance(repo_labels, list): print(f"ERROR: Expected list for repo labels, got {type(repo_labels)}", file=sys.stderr) sys.exit(1) ```
@ -0,0 +59,4 @@
repo_labels = api_request(token, "GET", f"{base}/labels")
label_id = next(
(label["id"] for label in repo_labels if label.get("name") == LABEL_NAME),
None,
Author
Owner

💡 SUGGESTION: The created variable assumes the response is a dict with an 'id' key. Add validation for robustness.

Suggested fix:

created = api_request(
    token,
    "POST",
    f"{base}/labels",
    {
        "name": LABEL_NAME,
        "color": "0e8a16",
        "description": "Drep AI review completed by Woodpecker",
    },
)
if not isinstance(created, dict) or "id" not in created:
    print(f"ERROR: Unexpected response when creating label: {created}", file=sys.stderr)
    sys.exit(1)
label_id = created["id"]
💡 **SUGGESTION**: The `created` variable assumes the response is a dict with an 'id' key. Add validation for robustness. **Suggested fix:** ```python created = api_request( token, "POST", f"{base}/labels", { "name": LABEL_NAME, "color": "0e8a16", "description": "Drep AI review completed by Woodpecker", }, ) if not isinstance(created, dict) or "id" not in created: print(f"ERROR: Unexpected response when creating label: {created}", file=sys.stderr) sys.exit(1) label_id = created["id"] ```
@ -0,0 +65,4 @@
created = api_request(
token,
"POST",
f"{base}/labels",
Author
Owner

ℹ️ INFO: Consider adding a success exit code explicitly for clarity, though sys.exit(0) is implicit.

Suggested fix:

print(f"Added label {LABEL_NAME!r} to PR #{pr}")
    sys.exit(0)
ℹ️ **INFO**: Consider adding a success exit code explicitly for clarity, though `sys.exit(0)` is implicit. **Suggested fix:** ```python print(f"Added label {LABEL_NAME!r} to PR #{pr}") sys.exit(0) ```
gitea reviewed 2026-07-09 19:21:13 +00:00
gitea left a comment
Author
Owner

Inline review comment generated by drep.

Inline review comment generated by drep.
@ -0,0 +27,4 @@
body = None
if data is not None:
headers["Content-Type"] = "application/json"
body = json.dumps(data).encode()
Author
Owner

💡 SUGGESTION: The return type dict | list is too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint.

Suggested fix:

def api_request(token: str, method: str, url: str, data: dict | None = None) -> dict:
    # Note: Gitea API returns dict for single objects, list for collections.
    # This function assumes dict response; callers expecting list should handle accordingly.
💡 **SUGGESTION**: The return type `dict | list` is too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint. **Suggested fix:** ```python def api_request(token: str, method: str, url: str, data: dict | None = None) -> dict: # Note: Gitea API returns dict for single objects, list for collections. # This function assumes dict response; callers expecting list should handle accordingly. ```
@ -0,0 +47,4 @@
token = require_env("GITEA_TOKEN")
owner = require_env("CI_REPO_OWNER")
repo = require_env("CI_REPO_NAME")
pr = require_env("CI_COMMIT_PULL_REQUEST")
Author
Owner

⚠️ WARNING: The issue variable is assumed to be a dict, but api_request can return a list. If the API returns a list (unlikely for /issues/{pr} but possible on error), this will fail with AttributeError.

Suggested fix:

issue = api_request(token, "GET", f"{base}/issues/{pr}")
if not isinstance(issue, dict):
    print(f"ERROR: Unexpected response type for issue: {type(issue)}", file=sys.stderr)
    sys.exit(1)
⚠️ **WARNING**: The `issue` variable is assumed to be a dict, but `api_request` can return a list. If the API returns a list (unlikely for `/issues/{pr}` but possible on error), this will fail with AttributeError. **Suggested fix:** ```python issue = api_request(token, "GET", f"{base}/issues/{pr}") if not isinstance(issue, dict): print(f"ERROR: Unexpected response type for issue: {type(issue)}", file=sys.stderr) sys.exit(1) ```
@ -0,0 +51,4 @@
base = f"{GITEA_URL}/api/v1/repos/{owner}/{repo}"
issue = api_request(token, "GET", f"{base}/issues/{pr}")
labels_on_pr = issue.get("labels", [])
Author
Owner

⚠️ WARNING: Same issue here - repo_labels is assumed to be a list but api_request returns dict | list. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail.

Suggested fix:

repo_labels = api_request(token, "GET", f"{base}/labels")
if not isinstance(repo_labels, list):
    print(f"ERROR: Expected list for repo labels, got {type(repo_labels)}", file=sys.stderr)
    sys.exit(1)
⚠️ **WARNING**: Same issue here - `repo_labels` is assumed to be a list but `api_request` returns `dict | list`. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail. **Suggested fix:** ```python repo_labels = api_request(token, "GET", f"{base}/labels") if not isinstance(repo_labels, list): print(f"ERROR: Expected list for repo labels, got {type(repo_labels)}", file=sys.stderr) sys.exit(1) ```
@ -0,0 +59,4 @@
repo_labels = api_request(token, "GET", f"{base}/labels")
label_id = next(
(label["id"] for label in repo_labels if label.get("name") == LABEL_NAME),
None,
Author
Owner

💡 SUGGESTION: The created variable assumes the response is a dict with an 'id' key. Add validation for robustness.

Suggested fix:

created = api_request(
    token,
    "POST",
    f"{base}/labels",
    {
        "name": LABEL_NAME,
        "color": "0e8a16",
        "description": "Drep AI review completed by Woodpecker",
    },
)
if not isinstance(created, dict) or "id" not in created:
    print(f"ERROR: Unexpected response when creating label: {created}", file=sys.stderr)
    sys.exit(1)
label_id = created["id"]
💡 **SUGGESTION**: The `created` variable assumes the response is a dict with an 'id' key. Add validation for robustness. **Suggested fix:** ```python created = api_request( token, "POST", f"{base}/labels", { "name": LABEL_NAME, "color": "0e8a16", "description": "Drep AI review completed by Woodpecker", }, ) if not isinstance(created, dict) or "id" not in created: print(f"ERROR: Unexpected response when creating label: {created}", file=sys.stderr) sys.exit(1) label_id = created["id"] ```
@ -0,0 +65,4 @@
created = api_request(
token,
"POST",
f"{base}/labels",
Author
Owner

ℹ️ INFO: Consider adding a success exit code explicitly for clarity, though sys.exit(0) is implicit.

Suggested fix:

print(f"Added label {LABEL_NAME!r} to PR #{pr}")
    sys.exit(0)
ℹ️ **INFO**: Consider adding a success exit code explicitly for clarity, though `sys.exit(0)` is implicit. **Suggested fix:** ```python print(f"Added label {LABEL_NAME!r} to PR #{pr}") sys.exit(0) ```
gitea reviewed 2026-07-09 19:21:13 +00:00
gitea left a comment
Author
Owner

Inline review comment generated by drep.

Inline review comment generated by drep.
@ -0,0 +27,4 @@
body = None
if data is not None:
headers["Content-Type"] = "application/json"
body = json.dumps(data).encode()
Author
Owner

💡 SUGGESTION: The return type dict | list is too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint.

Suggested fix:

def api_request(token: str, method: str, url: str, data: dict | None = None) -> dict:
    # Note: Gitea API returns dict for single objects, list for collections.
    # This function assumes dict response; callers expecting list should handle accordingly.
💡 **SUGGESTION**: The return type `dict | list` is too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint. **Suggested fix:** ```python def api_request(token: str, method: str, url: str, data: dict | None = None) -> dict: # Note: Gitea API returns dict for single objects, list for collections. # This function assumes dict response; callers expecting list should handle accordingly. ```
@ -0,0 +47,4 @@
token = require_env("GITEA_TOKEN")
owner = require_env("CI_REPO_OWNER")
repo = require_env("CI_REPO_NAME")
pr = require_env("CI_COMMIT_PULL_REQUEST")
Author
Owner

⚠️ WARNING: The issue variable is assumed to be a dict, but api_request can return a list. If the API returns a list (unlikely for /issues/{pr} but possible on error), this will fail with AttributeError.

Suggested fix:

issue = api_request(token, "GET", f"{base}/issues/{pr}")
if not isinstance(issue, dict):
    print(f"ERROR: Unexpected response type for issue: {type(issue)}", file=sys.stderr)
    sys.exit(1)
⚠️ **WARNING**: The `issue` variable is assumed to be a dict, but `api_request` can return a list. If the API returns a list (unlikely for `/issues/{pr}` but possible on error), this will fail with AttributeError. **Suggested fix:** ```python issue = api_request(token, "GET", f"{base}/issues/{pr}") if not isinstance(issue, dict): print(f"ERROR: Unexpected response type for issue: {type(issue)}", file=sys.stderr) sys.exit(1) ```
@ -0,0 +51,4 @@
base = f"{GITEA_URL}/api/v1/repos/{owner}/{repo}"
issue = api_request(token, "GET", f"{base}/issues/{pr}")
labels_on_pr = issue.get("labels", [])
Author
Owner

⚠️ WARNING: Same issue here - repo_labels is assumed to be a list but api_request returns dict | list. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail.

Suggested fix:

repo_labels = api_request(token, "GET", f"{base}/labels")
if not isinstance(repo_labels, list):
    print(f"ERROR: Expected list for repo labels, got {type(repo_labels)}", file=sys.stderr)
    sys.exit(1)
⚠️ **WARNING**: Same issue here - `repo_labels` is assumed to be a list but `api_request` returns `dict | list`. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail. **Suggested fix:** ```python repo_labels = api_request(token, "GET", f"{base}/labels") if not isinstance(repo_labels, list): print(f"ERROR: Expected list for repo labels, got {type(repo_labels)}", file=sys.stderr) sys.exit(1) ```
@ -0,0 +59,4 @@
repo_labels = api_request(token, "GET", f"{base}/labels")
label_id = next(
(label["id"] for label in repo_labels if label.get("name") == LABEL_NAME),
None,
Author
Owner

💡 SUGGESTION: The created variable assumes the response is a dict with an 'id' key. Add validation for robustness.

Suggested fix:

created = api_request(
    token,
    "POST",
    f"{base}/labels",
    {
        "name": LABEL_NAME,
        "color": "0e8a16",
        "description": "Drep AI review completed by Woodpecker",
    },
)
if not isinstance(created, dict) or "id" not in created:
    print(f"ERROR: Unexpected response when creating label: {created}", file=sys.stderr)
    sys.exit(1)
label_id = created["id"]
💡 **SUGGESTION**: The `created` variable assumes the response is a dict with an 'id' key. Add validation for robustness. **Suggested fix:** ```python created = api_request( token, "POST", f"{base}/labels", { "name": LABEL_NAME, "color": "0e8a16", "description": "Drep AI review completed by Woodpecker", }, ) if not isinstance(created, dict) or "id" not in created: print(f"ERROR: Unexpected response when creating label: {created}", file=sys.stderr) sys.exit(1) label_id = created["id"] ```
@ -0,0 +65,4 @@
created = api_request(
token,
"POST",
f"{base}/labels",
Author
Owner

ℹ️ INFO: Consider adding a success exit code explicitly for clarity, though sys.exit(0) is implicit.

Suggested fix:

print(f"Added label {LABEL_NAME!r} to PR #{pr}")
    sys.exit(0)
ℹ️ **INFO**: Consider adding a success exit code explicitly for clarity, though `sys.exit(0)` is implicit. **Suggested fix:** ```python print(f"Added label {LABEL_NAME!r} to PR #{pr}") sys.exit(0) ```
gitea added the
ai-reviewed
label 2026-07-09 19:21:14 +00:00
gitea merged commit d283a08555 into develop 2026-07-09 19:44:25 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gitea/test#36
No description provided.