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

Open Beginner friendly
#959 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
testing

Research direction

Start at pytest_splunk_addon/sample_generation/rule.py:684 and inspect the other randint call sites in that file. Reproduce the failure under Python 3.13 through the sample generation path, then verify that the affected calls accept integer bounds and that the knowledge/modinput test session completes without the INTERNALERROR.

Written by the indexing model from the issue text.

Description

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).

Dominant language
Python
Stars
66
Forks
21
Avg merge
4d 13h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from splunk/pytest-splunk-addon

All issues in splunk/pytest-splunk-addon

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.