Sync from GitHub via hub-sync (part 2)
Browse files- skillforge/mcp.py +9 -2
skillforge/mcp.py
CHANGED
|
@@ -237,10 +237,17 @@ class GitHubMCPWrapper:
|
|
| 237 |
Returns:
|
| 238 |
(success, pr_data)
|
| 239 |
"""
|
| 240 |
-
# Sanitize inputs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
title = re.sub(r'[<>\"\\]', '', title)[:100]
|
| 242 |
body = re.sub(r'[<>\\]', '', body)[:5000]
|
| 243 |
-
head = re.sub(r'[^a-zA-Z0-9\-_/]', '', head)[:
|
| 244 |
|
| 245 |
# Log for audit
|
| 246 |
logger.info(f"[WRITE] Creating PR in {repo}")
|
|
|
|
| 237 |
Returns:
|
| 238 |
(success, pr_data)
|
| 239 |
"""
|
| 240 |
+
# Sanitize inputs. NOTE: head must NOT be truncated to some arbitrary short
|
| 241 |
+
# length here — callers (agents/build_request.py, agents/skillforge_build.py)
|
| 242 |
+
# already pushed a real git branch under this exact name (often
|
| 243 |
+
# "vape-build-<issue>-<40-char-slug>-<timestamp>", 60-80 chars). Cutting it
|
| 244 |
+
# down after the fact produces a branch name that was never pushed, so
|
| 245 |
+
# GitHub's PR API 422s with "Validation Failed" (head branch not found) —
|
| 246 |
+
# confirmed via issue #67's build run. Git refs allow up to 255 bytes, so
|
| 247 |
+
# only strip disallowed characters, cap generously above what callers emit.
|
| 248 |
title = re.sub(r'[<>\"\\]', '', title)[:100]
|
| 249 |
body = re.sub(r'[<>\\]', '', body)[:5000]
|
| 250 |
+
head = re.sub(r'[^a-zA-Z0-9\-_/]', '', head)[:200]
|
| 251 |
|
| 252 |
# Log for audit
|
| 253 |
logger.info(f"[WRITE] Creating PR in {repo}")
|