Fix git not found error crashing document uploads in container
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 3m13s
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 3m13s
Install git in Docker image and wrap all subprocess git calls in try/except so a missing or failing git binary never kills an upload that already succeeded. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -87,7 +87,7 @@ VALUES (
|
||||
'752cebdd-6748-4a04-aacd-c7ab0294ef33',
|
||||
'agent_completion',
|
||||
'סוכן סיים משימה — נדרשת בדיקה והחלטה על הצעד הבא',
|
||||
'pending',
|
||||
'queued',
|
||||
'agent'
|
||||
);"
|
||||
```
|
||||
|
||||
@@ -90,7 +90,7 @@ VALUES (
|
||||
'752cebdd-6748-4a04-aacd-c7ab0294ef33',
|
||||
'agent_completion',
|
||||
'מייצא טיוטה סיים משימה — נדרשת בדיקה',
|
||||
'pending', 'agent'
|
||||
'queued', 'agent'
|
||||
);"
|
||||
```
|
||||
|
||||
|
||||
@@ -116,6 +116,6 @@ VALUES (
|
||||
'752cebdd-6748-4a04-aacd-c7ab0294ef33',
|
||||
'agent_completion',
|
||||
'מגיה מסמכים סיים משימה — נדרשת בדיקה',
|
||||
'pending', 'agent'
|
||||
'queued', 'agent'
|
||||
);"
|
||||
```
|
||||
|
||||
@@ -121,6 +121,6 @@ VALUES (
|
||||
'752cebdd-6748-4a04-aacd-c7ab0294ef33',
|
||||
'agent_completion',
|
||||
'בודק איכות סיים משימה — נדרשת בדיקה',
|
||||
'pending', 'agent'
|
||||
'queued', 'agent'
|
||||
);"
|
||||
```
|
||||
|
||||
@@ -110,7 +110,7 @@ VALUES (
|
||||
'752cebdd-6748-4a04-aacd-c7ab0294ef33',
|
||||
'agent_completion',
|
||||
'חוקר תקדימים סיים משימה — נדרשת בדיקה',
|
||||
'pending', 'agent'
|
||||
'queued', 'agent'
|
||||
);"
|
||||
```
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ VALUES (
|
||||
'752cebdd-6748-4a04-aacd-c7ab0294ef33',
|
||||
'agent_completion',
|
||||
'כותב החלטה סיים משימה — נדרשת בדיקה',
|
||||
'pending', 'agent'
|
||||
'queued', 'agent'
|
||||
);"
|
||||
```
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ WORKDIR /app
|
||||
|
||||
# Install Node.js 20.x
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl ca-certificates \
|
||||
curl ca-certificates git \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||
&& apt-get install -y --no-install-recommends nodejs \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
@@ -106,17 +106,20 @@ async def case_create(
|
||||
notes_file = case_dir / "notes.md"
|
||||
notes_file.write_text(f"# הערות - תיק {case_number}\n\n{notes}\n")
|
||||
|
||||
# Initialize git repo
|
||||
subprocess.run(["git", "init"], cwd=case_dir, capture_output=True)
|
||||
subprocess.run(["git", "add", "."], cwd=case_dir, capture_output=True)
|
||||
subprocess.run(
|
||||
["git", "commit", "-m", f"אתחול תיק {case_number}: {title}"],
|
||||
cwd=case_dir,
|
||||
capture_output=True,
|
||||
env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local",
|
||||
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
|
||||
"PATH": "/usr/bin:/bin"},
|
||||
)
|
||||
# Initialize git repo (best-effort)
|
||||
try:
|
||||
subprocess.run(["git", "init"], cwd=case_dir, capture_output=True)
|
||||
subprocess.run(["git", "add", "."], cwd=case_dir, capture_output=True)
|
||||
subprocess.run(
|
||||
["git", "commit", "-m", f"אתחול תיק {case_number}: {title}"],
|
||||
cwd=case_dir,
|
||||
capture_output=True,
|
||||
env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local",
|
||||
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
|
||||
"PATH": "/usr/bin:/bin"},
|
||||
)
|
||||
except Exception:
|
||||
pass # git not available — non-critical
|
||||
|
||||
return json.dumps(case, default=str, ensure_ascii=False, indent=2)
|
||||
|
||||
@@ -199,20 +202,23 @@ async def case_update(
|
||||
|
||||
updated = await db.update_case(UUID(case["id"]), **fields)
|
||||
|
||||
# Git commit the update
|
||||
case_dir = config.find_case_dir(case_number)
|
||||
if case_dir.exists():
|
||||
case_json = case_dir / "case.json"
|
||||
case_json.write_text(json.dumps(updated, default=str, ensure_ascii=False, indent=2))
|
||||
subprocess.run(["git", "add", "case.json"], cwd=case_dir, capture_output=True)
|
||||
subprocess.run(
|
||||
["git", "commit", "-m", f"עדכון תיק: {', '.join(fields.keys())}"],
|
||||
cwd=case_dir,
|
||||
capture_output=True,
|
||||
env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local",
|
||||
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
|
||||
"PATH": "/usr/bin:/bin"},
|
||||
)
|
||||
# Git commit the update (best-effort)
|
||||
try:
|
||||
case_dir = config.find_case_dir(case_number)
|
||||
if case_dir.exists():
|
||||
case_json = case_dir / "case.json"
|
||||
case_json.write_text(json.dumps(updated, default=str, ensure_ascii=False, indent=2))
|
||||
subprocess.run(["git", "add", "case.json"], cwd=case_dir, capture_output=True)
|
||||
subprocess.run(
|
||||
["git", "commit", "-m", f"עדכון תיק: {', '.join(fields.keys())}"],
|
||||
cwd=case_dir,
|
||||
capture_output=True,
|
||||
env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local",
|
||||
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
|
||||
"PATH": "/usr/bin:/bin"},
|
||||
)
|
||||
except Exception:
|
||||
pass # git not available — non-critical
|
||||
|
||||
return json.dumps(updated, default=str, ensure_ascii=False, indent=2)
|
||||
|
||||
|
||||
@@ -67,31 +67,34 @@ async def document_upload(
|
||||
await db.update_document(UUID(doc["id"]), doc_type=classified_type)
|
||||
doc["doc_type"] = classified_type
|
||||
|
||||
# Git commit
|
||||
repo_dir = config.find_case_dir(case_number)
|
||||
if repo_dir.exists():
|
||||
subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True)
|
||||
doc_type_hebrew = {
|
||||
"appeal": "כתב ערר",
|
||||
"response": "תשובה",
|
||||
"protocol": "פרוטוקול",
|
||||
"plan": "תכנית",
|
||||
"permit": "היתר",
|
||||
"court_decision": "פסק דין",
|
||||
"decision": "החלטה",
|
||||
"appraisal": "שומה",
|
||||
"objection": "התנגדות",
|
||||
"exhibit": "נספח",
|
||||
"reference": "מסמך עזר",
|
||||
}.get(actual_doc_type, actual_doc_type)
|
||||
subprocess.run(
|
||||
["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {title}"],
|
||||
cwd=repo_dir,
|
||||
capture_output=True,
|
||||
env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local",
|
||||
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
|
||||
"PATH": "/usr/bin:/bin"},
|
||||
)
|
||||
# Git commit (best-effort — don't fail upload on git errors)
|
||||
try:
|
||||
repo_dir = config.find_case_dir(case_number)
|
||||
if repo_dir.exists():
|
||||
subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True)
|
||||
doc_type_hebrew = {
|
||||
"appeal": "כתב ערר",
|
||||
"response": "תשובה",
|
||||
"protocol": "פרוטוקול",
|
||||
"plan": "תכנית",
|
||||
"permit": "היתר",
|
||||
"court_decision": "פסק דין",
|
||||
"decision": "החלטה",
|
||||
"appraisal": "שומה",
|
||||
"objection": "התנגדות",
|
||||
"exhibit": "נספח",
|
||||
"reference": "מסמך עזר",
|
||||
}.get(actual_doc_type, actual_doc_type)
|
||||
subprocess.run(
|
||||
["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {title}"],
|
||||
cwd=repo_dir,
|
||||
capture_output=True,
|
||||
env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local",
|
||||
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
|
||||
"PATH": "/usr/bin:/bin"},
|
||||
)
|
||||
except Exception:
|
||||
pass # git not available in container — non-critical
|
||||
|
||||
return json.dumps({
|
||||
"document": doc,
|
||||
|
||||
74
web/app.py
74
web/app.py
@@ -2565,25 +2565,28 @@ async def _process_tagged_document(task_id: str, dest: Path, case_number: str, c
|
||||
_progress[task_id] = {"status": "processing", "filename": display_name, "step": "extracting"}
|
||||
result = await processor.process_document(doc_id, case_id)
|
||||
|
||||
# Git commit + push
|
||||
repo_dir = config.find_case_dir(case_number)
|
||||
if repo_dir.exists():
|
||||
env = {
|
||||
"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local",
|
||||
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
|
||||
"PATH": "/usr/bin:/bin",
|
||||
}
|
||||
doc_type_hebrew = DOC_TYPE_NAMES.get(doc_type, doc_type)
|
||||
subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True)
|
||||
subprocess.run(
|
||||
["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {display_name}"],
|
||||
cwd=repo_dir, capture_output=True, env=env,
|
||||
)
|
||||
# Try to push to Gitea (non-blocking)
|
||||
subprocess.run(["git", "push"], cwd=repo_dir, capture_output=True, env={
|
||||
**env,
|
||||
"GIT_TERMINAL_PROMPT": "0",
|
||||
})
|
||||
# Git commit + push (best-effort — don't fail upload on git errors)
|
||||
try:
|
||||
repo_dir = config.find_case_dir(case_number)
|
||||
if repo_dir.exists():
|
||||
env = {
|
||||
"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local",
|
||||
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
|
||||
"PATH": "/usr/bin:/bin",
|
||||
}
|
||||
doc_type_hebrew = DOC_TYPE_NAMES.get(doc_type, doc_type)
|
||||
subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True)
|
||||
subprocess.run(
|
||||
["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {display_name}"],
|
||||
cwd=repo_dir, capture_output=True, env=env,
|
||||
)
|
||||
# Try to push to Gitea (non-blocking)
|
||||
subprocess.run(["git", "push"], cwd=repo_dir, capture_output=True, env={
|
||||
**env,
|
||||
"GIT_TERMINAL_PROMPT": "0",
|
||||
})
|
||||
except Exception:
|
||||
logger.warning("Git commit/push failed for %s (non-critical)", display_name)
|
||||
|
||||
_progress[task_id] = {
|
||||
"status": "completed",
|
||||
@@ -2821,21 +2824,24 @@ async def _process_case_document(task_id: str, source: Path, req: ClassifyReques
|
||||
_progress[task_id] = {"status": "processing", "filename": req.filename, "step": "extracting"}
|
||||
result = await processor.process_document(UUID(doc["id"]), case_id)
|
||||
|
||||
# Git commit
|
||||
repo_dir = config.find_case_dir(req.case_number)
|
||||
if repo_dir.exists():
|
||||
subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True)
|
||||
doc_type_hebrew = {
|
||||
"appeal": "כתב ערר", "response": "תשובה", "decision": "החלטה",
|
||||
"reference": "מסמך עזר", "exhibit": "נספח",
|
||||
}.get(req.doc_type, req.doc_type)
|
||||
subprocess.run(
|
||||
["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {title}"],
|
||||
cwd=repo_dir, capture_output=True,
|
||||
env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local",
|
||||
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
|
||||
"PATH": "/usr/bin:/bin"},
|
||||
)
|
||||
# Git commit (best-effort)
|
||||
try:
|
||||
repo_dir = config.find_case_dir(req.case_number)
|
||||
if repo_dir.exists():
|
||||
subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True)
|
||||
doc_type_hebrew = {
|
||||
"appeal": "כתב ערר", "response": "תשובה", "decision": "החלטה",
|
||||
"reference": "מסמך עזר", "exhibit": "נספח",
|
||||
}.get(req.doc_type, req.doc_type)
|
||||
subprocess.run(
|
||||
["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {title}"],
|
||||
cwd=repo_dir, capture_output=True,
|
||||
env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local",
|
||||
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
|
||||
"PATH": "/usr/bin:/bin"},
|
||||
)
|
||||
except Exception:
|
||||
logger.warning("Git commit failed for %s (non-critical)", req.filename)
|
||||
|
||||
# Remove from uploads
|
||||
source.unlink(missing_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user