Skip to content

fix(errors): keep the generic error code stable across restarts - #338

Merged
chigwell merged 1 commit into
chigwell:mainfrom
axisrow:fix/stable-error-codes
Oct 20, 2026
Merged

chigwell merged 1 commit into
chigwell:mainfrom
axisrow:fix/stable-error-codes

Conversation

@axisrow

@axisrow axisrow commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Summary

The generic error code in log_and_format_error was derived with abs(hash(function_name)) % 1000. Python salts str.__hash__ per process (PYTHONHASHSEED), so the same failure got a different code after every restart — useless for correlating logs across runs or matching against documented codes.

This switches the code to zlib.crc32(function_name.encode()) % 1000, which is stable across processes for the same input.

Testing

  • tests/test_error_logging.py asserts the code is reproducible across invocations.
  • Full suite: 1408 passed.

🤖 Generated with Claude Code

The code was built from hash(function_name), and str hash() is salted per process, so the same failure got a new code (CHAT-ERR-975, -324, -195 ...) after every restart of the server and could not be searched for or reported. Use zlib.crc32 instead.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018Xun6C4mXUAKbVSmiEEh79
@chigwell
chigwell merged commit 639090f into chigwell:main Oct 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants