Skip to content

fix(misc): three small defensive fixes salvaged from #1974#23591

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-1a485133
May 11, 2026
Merged

fix(misc): three small defensive fixes salvaged from #1974#23591
teknium1 merged 1 commit into
mainfrom
hermes/hermes-1a485133

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvages the 3 substantive low-severity fixes from @Gutslabs' #1974 "misc bug fixes" bundle. Closes #1974.

The other 8 claims in #1974 were either already fixed on main with superior implementations (state lock, firecrawl lazy import, fcntl/msvcrt guard, path normalization, schema migrations) or did not survive review (interrupt clear is immediately re-asserted; cron lock_fd is guaranteed non-None by the outer try; etc).

Changes

File Change
run_agent.py _materialize_data_url_for_vision — wrap b64decode+write in try/except, os.unlink the delete=False tempfile on failure
gateway/session.py append_to_transcript JSONL write wrapped in try/except OSError; SQLite write above is the primary store
gateway/status.py _read_pid_record catches OSError between exists() and read_text() for concurrent-restart race
tests/run_agent/test_materialize_data_url_cleanup.py New regression test: leak-on-failure + success path

Validation

Result
New tempfile-cleanup regression tests 2/2 pass
Targeted gateway suite (session/transcript/pid/status) 610/610 pass
Full gateway suite 5333/5337; 4 failures pre-existing on main (verified by stash+re-run), unrelated
py_compile on modified modules clean

Authorship preserved for @Gutslabs via rebase merge.

Salvages the three substantive low-severity fixes from Gutslabs' #1974
"misc bug fixes" bundle.  The other 8 claims in that PR were either
already fixed on main with superior implementations (state lock,
firecrawl lazy import, fcntl/msvcrt guard, path normalization, schema
migrations) or did not survive review.

- run_agent: `_materialize_data_url_for_vision` uses
  `NamedTemporaryFile(delete=False)`; if `base64.b64decode` raises on a
  corrupt data URL the temp file would persist forever.  Wrap the
  write in try/except and `os.unlink` the temp on failure.

- gateway/session: `append_to_transcript` JSONL write had no error
  handling, so disk-full / read-only-fs / permission errors crashed the
  message handler.  The SQLite write above is the primary store, so
  swallow OSError on the JSONL fallback with a debug log.

- gateway/status: `_read_pid_record` reads `pid_path.read_text()` after
  an `exists()` check; if the PID file is deleted between the two
  calls (concurrent gateway restart) we hit an unhandled OSError.
  Catch it and return None.

Adds a regression test for the tempfile cleanup; the other two paths
are defensive try/excepts on infrequent OSError that don't warrant
dedicated tests.

Co-authored-by: Teknium <127238744+teknium1@users.noreply.github.com>
@teknium1 teknium1 merged commit 3af3c4e into main May 11, 2026
12 of 15 checks passed
@teknium1 teknium1 deleted the hermes/hermes-1a485133 branch May 11, 2026 05:28
@teknium1 teknium1 mentioned this pull request May 11, 2026
5 tasks
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-1a485133 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8148 on HEAD, 8147 on base (🆕 +1)

🆕 New issues (1):

Rule Count
unresolved-import 1
First entries
tests/run_agent/test_materialize_data_url_cleanup.py:16: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`

✅ Fixed issues: none

Unchanged: 4281 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent loop, run_agent.py, prompt builder comp/gateway Gateway runner, session dispatch, delivery labels May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants