Repository navigation
fix: report out-of-range SSE timestamps as unparseable, not as a crash - #6
Open
JingHao-Leon wants to merge 2 commits into
Open
JingHao-Leon wants to merge 2 commits into
JingHao-Leon wants to merge 2 commits into
Conversation
parse_timestamp() only guards the epoch branch against ValueError. A value that matches the ISO / US / generalized shape but is impossible to represent (2026-02-30T10:00:00, an out-of-range UTC offset, a 13:00:00 PM clock hour) reaches datetime.strptime()/timezone() and raises out of the function. The value then escapes scan_package()'s error wrapping, so prepare-sse-data.py dies with a raw ValueError traceback instead of the PreparationError the tool already uses for every other bad value.
parse_timestamp() documented itself as returning None for "other data", but only the epoch branch actually guarded against ValueError. Every other branch fed a shape-matching value straight into datetime.strptime() or timezone(), so an impossible value (2026-02-30, a 13 o'clock PM hour, a +9999 UTC offset) escaped the function. The exception then escaped scan_package()'s error wrapping, and prepare-sse-data.py died with a raw ValueError traceback instead of the PreparationError it already raises for every other unusable value. parse_timestamp() now converts ValueError into the None it already promised, so the existing "unsupported temporal values" / "cannot parse embedded timestamp" paths handle these values.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parse_timestamp()in the SSE lab tooling promised to returnNoneforanything that is not a usable timestamp, but only its epoch branch actually
guarded against
ValueError. The ISO, US and generalized branches fed ashape-matching value straight into
datetime.strptime()/timezone(), so avalue that looks like a timestamp but is not a real instant (
2026-02-30,+9999, a13:00:00 PMhour) raised out of the function.The exception escaped
scan_package()'s error wrapping andprepare-sse-data.py'sexcept PreparationError, so the tool died with araw
ValueErrortraceback instead of the one-line error report it alreadyproduces for every other unusable value.
parse_timestamp()now convertsValueErrorinto theNoneit alreadypromised, so the existing
unsupported temporal values/cannot parse embedded timestamppaths handle these values.Fixes #5
Before / after
Reproducer: an SSE sample lookup whose
whenCreatedcell holds2026-02-30T10:00:00.Before:
After:
Exit code 1 in both cases — the difference is a one-line report versus a
traceback.
Root cause
installers/vmlab/sse_timestamps.py:88—parse_timestamponly wrapped theepoch branch in
try/except (OverflowError, ValueError). The remainingbranches could raise:
installers/vmlab/sse_timestamps.py:109—datetime.strptime(..., "%Y-%m-%d %H:%M:%S")installers/vmlab/sse_timestamps.py:113—_fixed_timezone()→timezone(), which rejects an offset outside ±24hinstallers/vmlab/sse_timestamps.py:128—datetime.strptime(..., "%m/%d/%Y %I:%M:%S %p")installers/vmlab/sse_timestamps.py:140—datetime.strptime(..., "%Y%m%d%H%M%S")The regexes feeding those calls only constrain a value's shape, so
2026-02-30and+9999match and leave the range check tostrptime/timezone.The raise then passed through the two places meant to contain it:
installers/vmlab/sse_data.py:246(only convertstarfile.TarError,UnicodeError,csv.ErrorandOSError) andinstallers/vmlab/prepare-sse-data.py:54(only handlesPreparationError).Verification
Run locally on Python 3.13.9:
pytest tests/vmlab/test_sse_data.py— 12 new cases fail before the fix(
ValueError: day is out of range for month) and pass after itpytest— 1840 passed, 13 failed; the 13 failures are the samepre-existing
tests/vmlab/test_script_config.py,tests/vmlab/test_sse_import_script.pyandtests/test_check_lengths.pycases that fail on an unmodified checkout too. They shell out to
/usr/bin/bash, which does not exist on macOS (it is/bin/bashthere) —that is why they cannot be verified locally, and they are unrelated to
this change.
ruff check .ruff format --check .mypy splunkctl/— unchanged from the base commit (3 pre-existing errorsin
splunkctl/mcp/dynamic_server.pyagainst the installed MCP SDK)mypy installers/vmlab/sse_timestamps.py installers/vmlab/sse_data.pybash scripts/check-lengths.sh— both changed files are within the500-line budget
Changelog: not touched — this repository has no per-PR changelog fragment
mechanism;
CHANGELOG.mdis written at release time.CI
The
CIworkflow is registered for this head SHA but is held ataction_required— the fork pull-request approval gate — so none of itssix jobs (
lint,typecheck,test,package,semgrep,docs) haverun. There are no job results for this commit, and
gh pr checkstherefore reports no checks for the branch. The verification listed above
was run locally.
This change was prepared with the assistance of an AI coding agent.