somratpro Claude Sonnet 4.6 commited on
Commit
ee98905
·
1 Parent(s): ddafed3

fix: make kanban patch and Docker build fully failure-safe

Browse files

- Wrap entire kanban patch in try/except so any error (encoding, permissions,
changed upstream file structure) skips silently instead of exiting 1
- Use errors='replace' when reading kanban_db.py to handle non-UTF-8 bytes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (2) hide show
  1. CHANGELOG.md +1 -0
  2. Dockerfile +40 -33
CHANGELOG.md CHANGED
@@ -8,6 +8,7 @@
8
  - **Unpinned jupyterlab breaks venv** — `uv pip install jupyterlab` without a version constraint could pull a release incompatible with existing Hermes venv packages. Pinned to `>=4.0,<5` range to bound resolution.
9
  - **`uv` not in PATH during Docker build** — switched from bare `uv` to explicit `/opt/hermes/.venv/bin/uv` so the install works regardless of base image PATH configuration.
10
  - **`visudo` not in PATH during Docker build** — switched to explicit `/usr/sbin/visudo` path.
 
11
 
12
  ## 0.2.0 - 2026-05-19
13
 
 
8
  - **Unpinned jupyterlab breaks venv** — `uv pip install jupyterlab` without a version constraint could pull a release incompatible with existing Hermes venv packages. Pinned to `>=4.0,<5` range to bound resolution.
9
  - **`uv` not in PATH during Docker build** — switched from bare `uv` to explicit `/opt/hermes/.venv/bin/uv` so the install works regardless of base image PATH configuration.
10
  - **`visudo` not in PATH during Docker build** — switched to explicit `/usr/sbin/visudo` path.
11
+ - **Kanban patch exits with code 1** — entire kanban migration patch now wrapped in `try/except`; any unexpected error (file encoding, permission, changed upstream structure) skips silently instead of failing the Docker build.
12
 
13
  ## 0.2.0 - 2026-05-19
14
 
Dockerfile CHANGED
@@ -59,41 +59,48 @@ RUN chmod +x \
59
 
60
  # Patch kanban migration: wrap ALTER TABLE ADD COLUMN in try/except so a
61
  # persisted DB with the column already present doesn't crash the gateway.
 
 
62
  RUN python3 - <<'PY'
63
- from pathlib import Path
64
  import sys
65
-
66
- p = Path("/opt/hermes/hermes_cli/kanban_db.py")
67
- if not p.exists():
68
- sys.exit(0)
69
-
70
- src = p.read_text(encoding="utf-8")
71
- sentinel = "# huggingmes: idempotent-alter"
72
- if sentinel in src:
73
- sys.exit(0)
74
-
75
- old = (
76
- ' conn.execute(\n'
77
- ' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
78
- ' "INTEGER NOT NULL DEFAULT 0"\n'
79
- ' )'
80
- )
81
- new = (
82
- f' try: {sentinel}\n'
83
- ' conn.execute(\n'
84
- ' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
85
- ' "INTEGER NOT NULL DEFAULT 0"\n'
86
- ' )\n'
87
- ' except Exception:\n'
88
- ' pass'
89
- )
90
-
91
- if old not in src:
92
- print("kanban patch: pattern not found — may be fixed upstream, skipping")
93
- sys.exit(0)
94
-
95
- p.write_text(src.replace(old, new), encoding="utf-8")
96
- print("kanban patch: applied")
 
 
 
 
 
 
97
  PY
98
 
99
  # Ensure hermes CLI is discoverable in ALL shell types (login, interactive,
 
59
 
60
  # Patch kanban migration: wrap ALTER TABLE ADD COLUMN in try/except so a
61
  # persisted DB with the column already present doesn't crash the gateway.
62
+ # Entire block wrapped in try/except — skips silently if Hermes fixes this
63
+ # upstream or the file structure changes.
64
  RUN python3 - <<'PY'
 
65
  import sys
66
+ try:
67
+ from pathlib import Path
68
+
69
+ p = Path("/opt/hermes/hermes_cli/kanban_db.py")
70
+ if not p.exists():
71
+ print("kanban patch: file not found, skipping")
72
+ sys.exit(0)
73
+
74
+ src = p.read_text(encoding="utf-8", errors="replace")
75
+ sentinel = "# huggingmes: idempotent-alter"
76
+ if sentinel in src:
77
+ print("kanban patch: already applied, skipping")
78
+ sys.exit(0)
79
+
80
+ old = (
81
+ ' conn.execute(\n'
82
+ ' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
83
+ ' "INTEGER NOT NULL DEFAULT 0"\n'
84
+ ' )'
85
+ )
86
+ new = (
87
+ f' try: {sentinel}\n'
88
+ ' conn.execute(\n'
89
+ ' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
90
+ ' "INTEGER NOT NULL DEFAULT 0"\n'
91
+ ' )\n'
92
+ ' except Exception:\n'
93
+ ' pass'
94
+ )
95
+
96
+ if old not in src:
97
+ print("kanban patch: pattern not found, may be fixed upstream, skipping")
98
+ sys.exit(0)
99
+
100
+ p.write_text(src.replace(old, new), encoding="utf-8")
101
+ print("kanban patch: applied")
102
+ except Exception as e:
103
+ print(f"kanban patch: error ({e}), skipping", file=sys.stderr)
104
  PY
105
 
106
  # Ensure hermes CLI is discoverable in ALL shell types (login, interactive,