Skip to content

fix: guard slice() against non-datetime timestamps and broken symlinks - #443

Merged
JarbasAl merged 1 commit into
devfrom
fix/log-parser-slice-typeerror
Sep 13, 2026
Merged

JarbasAl merged 1 commit into
devfrom
fix/log-parser-slice-typeerror

Conversation

@JarbasAl

@JarbasAl JarbasAl commented Sep 7, 2026

Copy link
Copy Markdown
Member

🤖 Auto-generated by Claude Sonnet 5 via Claude Code — NOT human-reviewed. Verify before acting.

This closes #261 and #227, which turned out to be two unrelated bugs sharing the same crash site (ovos-logs slice), not one root cause.

#261OVOSLogParser.parse() fell back to timestamp="" (a string) for a log line that doesn't match LOG_PATTERN (e.g. one missing a field) before any timestamped line has been seen. slice() then compared that string against datetime bounds with start <= log.timestamp < end and raised TypeError: '<=' not supported between instances of 'datetime.datetime' and 'str'. parse() now falls back to None, matching LogLine's declared type, and slice() skips entries whose timestamp is None.

#227get_log_path() used os.path.exists() to check whether a service's log file is present, which returns False for a broken symlink even though get_available_logs() (which uses os.listdir()) lists it as available. That mismatch let a service that "exists" from the CLI's point of view get None back for its log directory, which then blew up os.path.join(None, ...) with TypeError: expected str, bytes or os.PathLike object, not NoneType. This matches the collaborator's comment on #227 pointing at symlinked logs under ~/.local/state/mycroft. Switched to os.path.lexists() so both functions agree on what counts as present.

Both were reproduced against current dev (traceback matches each issue), with regression tests that fail before each fix and pass after. Full existing test suite is unaffected: 1002 passed, 9 pre-existing failures unrelated to this code (bus-client SessionManager API drift and a langcodes macrolanguage assertion), 1 skipped — same counts before and after this change.

Two unrelated bugs in the ovos-logs CLI:

- OVOSLogParser.parse() fell back to timestamp="" (a string) for a log
  line that fails to match LOG_PATTERN before any timestamped line has
  been seen. slice() then compared that string against datetime bounds
  and raised TypeError. parse() now falls back to None (matching
  LogLine's declared type) and slice() skips entries with no timestamp.

- get_log_path() used os.path.exists() to test for a service's log
  file, which returns False for a broken symlink even though the entry
  is listed by get_available_logs()'s os.listdir()-based scan. That
  mismatch let a service that "exists" get None back for its log
  directory, which then blew up os.path.join(). Switched to
  os.path.lexists() so both functions agree on what counts as present.

Both were reproduced against dev, regression tests added that fail
before each fix and pass after. Full existing suite unaffected (1002
passed, 9 pre-existing unrelated failures, before and after).

Closes #261
Closes #227

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the fix label Sep 7, 2026
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

The automated pipeline has reached its destination. 🏁

I've aggregated the results of the automated checks for this PR below.

🏷️ Release Preview

The release candidate is looking strong. 💪

Current: 0.14.2a1Next: 0.14.3a1

Signal Value
Label (none)
PR title fix: guard slice() against non-datetime timestamps and broken symlinks
Bump build

✅ PR title follows conventional commit format.


🚀 Release Channel Compatibility

Predicted next version: 0.14.3a1

Channel Status Note Current Constraint
Stable Too new (must be <0.9.0) ovos-utils>=0.8.1,<0.9.0
Testing Too new (must be <0.8.5) ovos-utils>=0.8.4,<0.8.5
Alpha Compatible ovos-utils>=0.14.2a1

⚖️ License Check

Keeping the lawyers happy, one file at a time. 👔

✅ No license violations found.

Policy: Apache 2.0 (universal donor). StrongCopyleft / NetworkCopyleft / WeakCopyleft / Other / Error categories fail. MPL allowed.

🔒 Security (pip-audit)

Ensuring our digital fortress remains impenetrable. 🏰

✅ No known vulnerabilities found (47 packages scanned).

📋 Repo Health

Ensuring the repo is ready for a marathon (aka long-term support). 🏁

✅ All required files present.

Latest Version: 0.14.2a1

ovos_utils/version.py — Version file
README.md — README
LICENSE — License file
pyproject.toml — pyproject.toml
⚠️ setup.py — setup.py
CHANGELOG.md — Changelog
ovos_utils/version.py has valid version block markers

🔍 Lint

I've finished my task! Here's the data you need. 📊

ruff: issues found — see job log

📊 Coverage

I've been crunching the numbers! Here's how the test coverage changed. 📈

85.5% total coverage

Files below 80% coverage (5 files)
File Coverage Missing lines
ovos_utils/log_parser.py 48.4% 225
ovos_utils/__init__.py 63.6% 16
ovos_utils/file_utils.py 74.4% 56
ovos_utils/thread_utils.py 76.9% 12
ovos_utils/geolocation.py 78.4% 22

Full report: download the coverage-report artifact.

🔨 Build Tests

Compiling thoughts and code into something real. 🧠

✅ All versions pass

Python Build Install Tests
3.10
3.11
3.12
3.13
3.14

Your 24/7 automated code reviewer 🌙

@JarbasAl
JarbasAl marked this pull request as ready for review September 13, 2026 16:55
@JarbasAl
JarbasAl merged commit 54c5d2c into dev Sep 13, 2026
14 checks passed
@JarbasAl
JarbasAl deleted the fix/log-parser-slice-typeerror branch September 13, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ovos-logs TypeError in log_parser.py ~372

1 participant