fix: guard slice() against non-datetime timestamps and broken symlinks - #443
Conversation
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>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The automated pipeline has reached its destination. 🏁I've aggregated the results of the automated checks for this PR below. 🏷️ Release PreviewThe release candidate is looking strong. 💪 Current:
✅ PR title follows conventional commit format. 🚀 Release Channel Compatibility Predicted next version:
⚖️ License CheckKeeping 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 HealthEnsuring the repo is ready for a marathon (aka long-term support). 🏁 ✅ All required files present. Latest Version: ✅ 🔍 LintI've finished my task! Here's the data you need. 📊 ❌ ruff: issues found — see job log 📊 CoverageI've been crunching the numbers! Here's how the test coverage changed. 📈 ✅ 85.5% total coverage Files below 80% coverage (5 files)
Full report: download the 🔨 Build TestsCompiling thoughts and code into something real. 🧠 ✅ All versions pass
Your 24/7 automated code reviewer 🌙 |
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.#261 —
OVOSLogParser.parse()fell back totimestamp=""(a string) for a log line that doesn't matchLOG_PATTERN(e.g. one missing a field) before any timestamped line has been seen.slice()then compared that string againstdatetimebounds withstart <= log.timestamp < endand raisedTypeError: '<=' not supported between instances of 'datetime.datetime' and 'str'.parse()now falls back toNone, matchingLogLine's declared type, andslice()skips entries whose timestamp isNone.#227 —
get_log_path()usedos.path.exists()to check whether a service's log file is present, which returnsFalsefor a broken symlink even thoughget_available_logs()(which usesos.listdir()) lists it as available. That mismatch let a service that "exists" from the CLI's point of view getNoneback for its log directory, which then blew upos.path.join(None, ...)withTypeError: 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 toos.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-clientSessionManagerAPI drift and alangcodesmacrolanguage assertion), 1 skipped — same counts before and after this change.