Skip to content

sample_generation/rule.py randint() crashes under Python 3.13 (float args no longer accepted) #959

Description

@mkolasinski-splunk

Under Python 3.13, random.randint(earliest_in_epoch, latest_in_epoch) in pytest_splunk_addon/sample_generation/rule.py:684 raises TypeError: 'float' object cannot be interpreted as an integer. Python 3.13 tightened random.randrange to reject non-integer arguments outright — on earlier versions (e.g. 3.9) this was only a DeprecationWarning.

This crashes pytest_sessionstart inside AppTestGenerator (via sample_generator.get_samples()rule.apply()rule.replace()), so pytest exits with INTERNALERROR, produces no JUnit XML report, and the whole test session fails before any test runs.

Repro: run any TA's knowledge/modinput tests with python-version: 3.13 in wfe-test-runner-action. Example: splunk-add-on-for-microsoft-sysmon run 29721237033, job run-knowledge-tests (10.4.1)https://github.com/splunk/splunk-add-on-for-microsoft-sysmon/actions/runs/29721237033/job/88285117187

INTERNALERROR>   File ".../pytest_splunk_addon/sample_generation/rule.py", line 684, in replace
INTERNALERROR>     randint(earliest_in_epoch, latest_in_epoch)
INTERNALERROR>   File "/usr/lib/python3.13/random.py", line 340, in randint
INTERNALERROR>     return self.randrange(a, b+1)
INTERNALERROR>   File "/usr/lib/python3.13/random.py", line 305, in randrange
INTERNALERROR>     istart = _index(start)
INTERNALERROR> TypeError: 'float' object cannot be interpreted as an integer

Fix should coerce earliest_in_epoch/latest_in_epoch (and any other randint call sites in this file) to int before calling randint.

Found while validating ADDON-89094's Python 3.9→3.13 bump for addonfactory-workflow-addon-release's v5.6.0 release (ADDON-88923 epic).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions