***v34 #34

Merged
gitea merged 1 commits from mitch into develop 2026-07-09 19:16:09 +00:00
Owner
No description provided.
gitea added 1 commit 2026-07-09 19:14:28 +00:00
V34
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline failed
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
5adf571e0a
Author
Owner

🤖 drep AI Code Review

The PR replaces a complex shell pipeline with a cleaner Python script for adding the 'ai-reviewed' label to PRs. This is a good refactoring. However, the Python code lacks error handling for HTTP errors, timeouts, and missing environment variables. These should be addressed before merging to ensure the CI step fails gracefully with actionable error messages rather than cryptic tracebacks.

Recommendation: 🔍 Needs Changes

Concerns:

  • Missing HTTP error handling in API calls
  • No timeout on network requests
  • No validation of required environment variables

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

## 🤖 drep AI Code Review The PR replaces a complex shell pipeline with a cleaner Python script for adding the 'ai-reviewed' label to PRs. This is a good refactoring. However, the Python code lacks error handling for HTTP errors, timeouts, and missing environment variables. These should be addressed before merging to ensure the CI step fails gracefully with actionable error messages rather than cryptic tracebacks. **Recommendation:** 🔍 Needs Changes **Concerns:** - Missing HTTP error handling in API calls - No timeout on network requests - No validation of required environment variables --- *Generated by drep using nvidia/nemotron-3-ultra-550b-a55b:free*
gitea reviewed 2026-07-09 19:14:43 +00:00
gitea left a comment
Author
Owner

Inline review comment generated by drep.

Inline review comment generated by drep.
@ -76,2 +76,2 @@
GITEA_API="https://gitea.git.mitchecp.com/api/v1"
REPO_API="${GITEA_API}/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}"
sed 's/^ //' <<'PY' | python3
import json
Author
Owner

⚠️ WARNING: The api function doesn't handle HTTP errors. urllib.request.urlopen raises urllib.error.HTTPError for 4xx/5xx responses, which will crash the script without a clear error message. Add try/except to handle API errors gracefully.

Suggested fix:

import urllib.error

        def api(method, path, data=None):
            headers = {'Authorization': f'token {token}'}
            body = None
            if data is not None:
                headers['Content-Type'] = 'application/json'
                body = json.dumps(data).encode()
            req = urllib.request.Request(f'{base}{path}', data=body, headers=headers, method=method)
            try:
                with urllib.request.urlopen(req, timeout=30) as resp:
                    return json.load(resp)
            except urllib.error.HTTPError as e:
                error_body = e.read().decode()
                raise RuntimeError(f'API {method} {path} failed: {e.code} {e.reason} - {error_body}')
⚠️ **WARNING**: The `api` function doesn't handle HTTP errors. `urllib.request.urlopen` raises `urllib.error.HTTPError` for 4xx/5xx responses, which will crash the script without a clear error message. Add try/except to handle API errors gracefully. **Suggested fix:** ```python import urllib.error def api(method, path, data=None): headers = {'Authorization': f'token {token}'} body = None if data is not None: headers['Content-Type'] = 'application/json' body = json.dumps(data).encode() req = urllib.request.Request(f'{base}{path}', data=body, headers=headers, method=method) try: with urllib.request.urlopen(req, timeout=30) as resp: return json.load(resp) except urllib.error.HTTPError as e: error_body = e.read().decode() raise RuntimeError(f'API {method} {path} failed: {e.code} {e.reason} - {error_body}') ```
Author
Owner

💡 SUGGESTION: No timeout on urlopen call. Network requests should always have a timeout to prevent hanging indefinitely.

Suggested fix:

with urllib.request.urlopen(req, timeout=30) as resp:
💡 **SUGGESTION**: No timeout on `urlopen` call. Network requests should always have a timeout to prevent hanging indefinitely. **Suggested fix:** ```python with urllib.request.urlopen(req, timeout=30) as resp: ```
Author
Owner

💡 SUGGESTION: Using os.environ['KEY'] raises KeyError if variable is missing. Consider using os.getenv() with explicit validation for better error messages.

Suggested fix:

token = os.getenv('GITEA_TOKEN')
        owner = os.getenv('CI_REPO_OWNER')
        repo = os.getenv('CI_REPO_NAME')
        pr = os.getenv('CI_COMMIT_PULL_REQUEST')
        for var, name in [(token, 'GITEA_TOKEN'), (owner, 'CI_REPO_OWNER'), (repo, 'CI_REPO_NAME'), (pr, 'CI_COMMIT_PULL_REQUEST')]:
            if not var:
                raise RuntimeError(f'Missing required environment variable: {name}')
💡 **SUGGESTION**: Using `os.environ['KEY']` raises KeyError if variable is missing. Consider using `os.getenv()` with explicit validation for better error messages. **Suggested fix:** ```python token = os.getenv('GITEA_TOKEN') owner = os.getenv('CI_REPO_OWNER') repo = os.getenv('CI_REPO_NAME') pr = os.getenv('CI_COMMIT_PULL_REQUEST') for var, name in [(token, 'GITEA_TOKEN'), (owner, 'CI_REPO_OWNER'), (repo, 'CI_REPO_NAME'), (pr, 'CI_COMMIT_PULL_REQUEST')]: if not var: raise RuntimeError(f'Missing required environment variable: {name}') ```
Author
Owner

ℹ️ INFO: Good improvement: replacing shell+curl+python one-liners with a proper Python script improves readability and maintainability. The api helper function is a clean abstraction.

ℹ️ **INFO**: Good improvement: replacing shell+curl+python one-liners with a proper Python script improves readability and maintainability. The `api` helper function is a clean abstraction.
gitea reviewed 2026-07-09 19:14:43 +00:00
gitea left a comment
Author
Owner

Inline review comment generated by drep.

Inline review comment generated by drep.
@ -76,2 +76,2 @@
GITEA_API="https://gitea.git.mitchecp.com/api/v1"
REPO_API="${GITEA_API}/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}"
sed 's/^ //' <<'PY' | python3
import json
Author
Owner

⚠️ WARNING: The api function doesn't handle HTTP errors. urllib.request.urlopen raises urllib.error.HTTPError for 4xx/5xx responses, which will crash the script without a clear error message. Add try/except to handle API errors gracefully.

Suggested fix:

import urllib.error

        def api(method, path, data=None):
            headers = {'Authorization': f'token {token}'}
            body = None
            if data is not None:
                headers['Content-Type'] = 'application/json'
                body = json.dumps(data).encode()
            req = urllib.request.Request(f'{base}{path}', data=body, headers=headers, method=method)
            try:
                with urllib.request.urlopen(req, timeout=30) as resp:
                    return json.load(resp)
            except urllib.error.HTTPError as e:
                error_body = e.read().decode()
                raise RuntimeError(f'API {method} {path} failed: {e.code} {e.reason} - {error_body}')
⚠️ **WARNING**: The `api` function doesn't handle HTTP errors. `urllib.request.urlopen` raises `urllib.error.HTTPError` for 4xx/5xx responses, which will crash the script without a clear error message. Add try/except to handle API errors gracefully. **Suggested fix:** ```python import urllib.error def api(method, path, data=None): headers = {'Authorization': f'token {token}'} body = None if data is not None: headers['Content-Type'] = 'application/json' body = json.dumps(data).encode() req = urllib.request.Request(f'{base}{path}', data=body, headers=headers, method=method) try: with urllib.request.urlopen(req, timeout=30) as resp: return json.load(resp) except urllib.error.HTTPError as e: error_body = e.read().decode() raise RuntimeError(f'API {method} {path} failed: {e.code} {e.reason} - {error_body}') ```
Author
Owner

💡 SUGGESTION: No timeout on urlopen call. Network requests should always have a timeout to prevent hanging indefinitely.

Suggested fix:

with urllib.request.urlopen(req, timeout=30) as resp:
💡 **SUGGESTION**: No timeout on `urlopen` call. Network requests should always have a timeout to prevent hanging indefinitely. **Suggested fix:** ```python with urllib.request.urlopen(req, timeout=30) as resp: ```
Author
Owner

💡 SUGGESTION: Using os.environ['KEY'] raises KeyError if variable is missing. Consider using os.getenv() with explicit validation for better error messages.

Suggested fix:

token = os.getenv('GITEA_TOKEN')
        owner = os.getenv('CI_REPO_OWNER')
        repo = os.getenv('CI_REPO_NAME')
        pr = os.getenv('CI_COMMIT_PULL_REQUEST')
        for var, name in [(token, 'GITEA_TOKEN'), (owner, 'CI_REPO_OWNER'), (repo, 'CI_REPO_NAME'), (pr, 'CI_COMMIT_PULL_REQUEST')]:
            if not var:
                raise RuntimeError(f'Missing required environment variable: {name}')
💡 **SUGGESTION**: Using `os.environ['KEY']` raises KeyError if variable is missing. Consider using `os.getenv()` with explicit validation for better error messages. **Suggested fix:** ```python token = os.getenv('GITEA_TOKEN') owner = os.getenv('CI_REPO_OWNER') repo = os.getenv('CI_REPO_NAME') pr = os.getenv('CI_COMMIT_PULL_REQUEST') for var, name in [(token, 'GITEA_TOKEN'), (owner, 'CI_REPO_OWNER'), (repo, 'CI_REPO_NAME'), (pr, 'CI_COMMIT_PULL_REQUEST')]: if not var: raise RuntimeError(f'Missing required environment variable: {name}') ```
Author
Owner

ℹ️ INFO: Good improvement: replacing shell+curl+python one-liners with a proper Python script improves readability and maintainability. The api helper function is a clean abstraction.

ℹ️ **INFO**: Good improvement: replacing shell+curl+python one-liners with a proper Python script improves readability and maintainability. The `api` helper function is a clean abstraction.
gitea reviewed 2026-07-09 19:14:43 +00:00
gitea left a comment
Author
Owner

Inline review comment generated by drep.

Inline review comment generated by drep.
@ -76,2 +76,2 @@
GITEA_API="https://gitea.git.mitchecp.com/api/v1"
REPO_API="${GITEA_API}/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}"
sed 's/^ //' <<'PY' | python3
import json
Author
Owner

⚠️ WARNING: The api function doesn't handle HTTP errors. urllib.request.urlopen raises urllib.error.HTTPError for 4xx/5xx responses, which will crash the script without a clear error message. Add try/except to handle API errors gracefully.

Suggested fix:

import urllib.error

        def api(method, path, data=None):
            headers = {'Authorization': f'token {token}'}
            body = None
            if data is not None:
                headers['Content-Type'] = 'application/json'
                body = json.dumps(data).encode()
            req = urllib.request.Request(f'{base}{path}', data=body, headers=headers, method=method)
            try:
                with urllib.request.urlopen(req, timeout=30) as resp:
                    return json.load(resp)
            except urllib.error.HTTPError as e:
                error_body = e.read().decode()
                raise RuntimeError(f'API {method} {path} failed: {e.code} {e.reason} - {error_body}')
⚠️ **WARNING**: The `api` function doesn't handle HTTP errors. `urllib.request.urlopen` raises `urllib.error.HTTPError` for 4xx/5xx responses, which will crash the script without a clear error message. Add try/except to handle API errors gracefully. **Suggested fix:** ```python import urllib.error def api(method, path, data=None): headers = {'Authorization': f'token {token}'} body = None if data is not None: headers['Content-Type'] = 'application/json' body = json.dumps(data).encode() req = urllib.request.Request(f'{base}{path}', data=body, headers=headers, method=method) try: with urllib.request.urlopen(req, timeout=30) as resp: return json.load(resp) except urllib.error.HTTPError as e: error_body = e.read().decode() raise RuntimeError(f'API {method} {path} failed: {e.code} {e.reason} - {error_body}') ```
Author
Owner

💡 SUGGESTION: No timeout on urlopen call. Network requests should always have a timeout to prevent hanging indefinitely.

Suggested fix:

with urllib.request.urlopen(req, timeout=30) as resp:
💡 **SUGGESTION**: No timeout on `urlopen` call. Network requests should always have a timeout to prevent hanging indefinitely. **Suggested fix:** ```python with urllib.request.urlopen(req, timeout=30) as resp: ```
Author
Owner

💡 SUGGESTION: Using os.environ['KEY'] raises KeyError if variable is missing. Consider using os.getenv() with explicit validation for better error messages.

Suggested fix:

token = os.getenv('GITEA_TOKEN')
        owner = os.getenv('CI_REPO_OWNER')
        repo = os.getenv('CI_REPO_NAME')
        pr = os.getenv('CI_COMMIT_PULL_REQUEST')
        for var, name in [(token, 'GITEA_TOKEN'), (owner, 'CI_REPO_OWNER'), (repo, 'CI_REPO_NAME'), (pr, 'CI_COMMIT_PULL_REQUEST')]:
            if not var:
                raise RuntimeError(f'Missing required environment variable: {name}')
💡 **SUGGESTION**: Using `os.environ['KEY']` raises KeyError if variable is missing. Consider using `os.getenv()` with explicit validation for better error messages. **Suggested fix:** ```python token = os.getenv('GITEA_TOKEN') owner = os.getenv('CI_REPO_OWNER') repo = os.getenv('CI_REPO_NAME') pr = os.getenv('CI_COMMIT_PULL_REQUEST') for var, name in [(token, 'GITEA_TOKEN'), (owner, 'CI_REPO_OWNER'), (repo, 'CI_REPO_NAME'), (pr, 'CI_COMMIT_PULL_REQUEST')]: if not var: raise RuntimeError(f'Missing required environment variable: {name}') ```
Author
Owner

ℹ️ INFO: Good improvement: replacing shell+curl+python one-liners with a proper Python script improves readability and maintainability. The api helper function is a clean abstraction.

ℹ️ **INFO**: Good improvement: replacing shell+curl+python one-liners with a proper Python script improves readability and maintainability. The `api` helper function is a clean abstraction.
gitea reviewed 2026-07-09 19:14:43 +00:00
gitea left a comment
Author
Owner

Inline review comment generated by drep.

Inline review comment generated by drep.
@ -76,2 +76,2 @@
GITEA_API="https://gitea.git.mitchecp.com/api/v1"
REPO_API="${GITEA_API}/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}"
sed 's/^ //' <<'PY' | python3
import json
Author
Owner

⚠️ WARNING: The api function doesn't handle HTTP errors. urllib.request.urlopen raises urllib.error.HTTPError for 4xx/5xx responses, which will crash the script without a clear error message. Add try/except to handle API errors gracefully.

Suggested fix:

import urllib.error

        def api(method, path, data=None):
            headers = {'Authorization': f'token {token}'}
            body = None
            if data is not None:
                headers['Content-Type'] = 'application/json'
                body = json.dumps(data).encode()
            req = urllib.request.Request(f'{base}{path}', data=body, headers=headers, method=method)
            try:
                with urllib.request.urlopen(req, timeout=30) as resp:
                    return json.load(resp)
            except urllib.error.HTTPError as e:
                error_body = e.read().decode()
                raise RuntimeError(f'API {method} {path} failed: {e.code} {e.reason} - {error_body}')
⚠️ **WARNING**: The `api` function doesn't handle HTTP errors. `urllib.request.urlopen` raises `urllib.error.HTTPError` for 4xx/5xx responses, which will crash the script without a clear error message. Add try/except to handle API errors gracefully. **Suggested fix:** ```python import urllib.error def api(method, path, data=None): headers = {'Authorization': f'token {token}'} body = None if data is not None: headers['Content-Type'] = 'application/json' body = json.dumps(data).encode() req = urllib.request.Request(f'{base}{path}', data=body, headers=headers, method=method) try: with urllib.request.urlopen(req, timeout=30) as resp: return json.load(resp) except urllib.error.HTTPError as e: error_body = e.read().decode() raise RuntimeError(f'API {method} {path} failed: {e.code} {e.reason} - {error_body}') ```
Author
Owner

💡 SUGGESTION: No timeout on urlopen call. Network requests should always have a timeout to prevent hanging indefinitely.

Suggested fix:

with urllib.request.urlopen(req, timeout=30) as resp:
💡 **SUGGESTION**: No timeout on `urlopen` call. Network requests should always have a timeout to prevent hanging indefinitely. **Suggested fix:** ```python with urllib.request.urlopen(req, timeout=30) as resp: ```
Author
Owner

💡 SUGGESTION: Using os.environ['KEY'] raises KeyError if variable is missing. Consider using os.getenv() with explicit validation for better error messages.

Suggested fix:

token = os.getenv('GITEA_TOKEN')
        owner = os.getenv('CI_REPO_OWNER')
        repo = os.getenv('CI_REPO_NAME')
        pr = os.getenv('CI_COMMIT_PULL_REQUEST')
        for var, name in [(token, 'GITEA_TOKEN'), (owner, 'CI_REPO_OWNER'), (repo, 'CI_REPO_NAME'), (pr, 'CI_COMMIT_PULL_REQUEST')]:
            if not var:
                raise RuntimeError(f'Missing required environment variable: {name}')
💡 **SUGGESTION**: Using `os.environ['KEY']` raises KeyError if variable is missing. Consider using `os.getenv()` with explicit validation for better error messages. **Suggested fix:** ```python token = os.getenv('GITEA_TOKEN') owner = os.getenv('CI_REPO_OWNER') repo = os.getenv('CI_REPO_NAME') pr = os.getenv('CI_COMMIT_PULL_REQUEST') for var, name in [(token, 'GITEA_TOKEN'), (owner, 'CI_REPO_OWNER'), (repo, 'CI_REPO_NAME'), (pr, 'CI_COMMIT_PULL_REQUEST')]: if not var: raise RuntimeError(f'Missing required environment variable: {name}') ```
Author
Owner

ℹ️ INFO: Good improvement: replacing shell+curl+python one-liners with a proper Python script improves readability and maintainability. The api helper function is a clean abstraction.

ℹ️ **INFO**: Good improvement: replacing shell+curl+python one-liners with a proper Python script improves readability and maintainability. The `api` helper function is a clean abstraction.
gitea merged commit 6f55f05e88 into develop 2026-07-09 19:16:09 +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#34
No description provided.