JSONResultsReader iterator called on oneshot search does not iterate with for loop.

Aperta
#678 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start by reproducing the provided JSONResultsReader snippet with both oneshot and normal searches, then inspect the JSONResultsReader iterator entry point and any existing tests. Done means a reader from a oneshot search supports direct for-loop iteration without first converting it to a list, with coverage for the differing search modes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Describe the bug
JSONResultsReader iterator called on oneshot search does not iterate with for loop.

To Reproduce
-run a oneshot search, the notice the for content/command[s] fails.

reader = JSONResultsReader(result_stream)
for item in reader:
    print(item)

Expected behavior
iterate through the results and take action on.

Logs or Screenshots
If applicable, add logs or screenshots to help explain your problem.

Splunk (please complete the following information):

  • Version: Splunk Enterprise 9.1.1
  • OS: Rocky Linux 9.6
  • Deployment: Distributed/Clustered SH's and IDX's architecture

SDK (please complete the following information):

  • Version: [2.1.0 and 2.1.1]
  • Language Runtime Version: Python 3.12.3
  • OS: Ubuntu 24.04.2 LTS

Additional context
This issue is only impacting the "oneshot" type search, with "normal" type search successfully yields an iterable "reader" for reader = JSONResultsReader(result_stream).

The workaround is to do:

reader = JSONResultsReader(result_stream)
reader2 = list(reader)
for item in reader2:
    print(item)
Lingua principale
Python
Stelle
743
Fork
387
Merge medio
42m
PR unite (30g)
4

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di splunk/splunk-sdk-python

Tutte le issue di splunk/splunk-sdk-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.