Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

jsonpath-ng incorrectly parsing the P4IRTree.program JSON

Aperta
#697 0 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
compilers

Direzione di ricerca

Start with SAI/utils/p4ir/p4ir_tree.py, especially P4IRTree.walk and its jsonpath_exp.find(self.program) call. Trace the match into SAI/utils/p4ir/p4ir_var_info.py, where Source_Info is read, and reproduce through sai_api_gen.py. Done means matching P4 IR nodes retain the expected dictionary structure so Source_Info can be indexed without the reported TypeError.

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

Descrizione

I opened an issue in the jsonpath-ng package as well because I believe this to be the root cause
https://github.com/h2non/jsonpath-ng/issues/216

When P4IRTree.walk calls jsonpath_exp.find(self.program) the returned matches have stripped the original JSON dictionary's formatting and there are lists in the place of dicts, this causes an indexing error later when "Source_Info" is read

Traceback (most recent call last):
08:46:42    File "dash-sai/DASH/dash-pipeline/SAI/./sai_api_gen.py", line 44, in <module>
08:46:42      var_ref_graph = P4VarRefGraph(p4ir)
08:46:42                      ^^^^^^^^^^^^^^^^^^^
08:46:42    File "dash-sai/DASH/dash-pipeline/SAI/utils/p4ir/p4ir_var_ref_graph.py", line 15, in __init__
08:46:42      self.__build_graph()
08:46:42    File "dash-sai/DASH/dash-pipeline/SAI/utils/p4ir/p4ir_var_ref_graph.py", line 18, in __build_graph
08:46:42      self.__build_counter_list()
08:46:42    File "dash-sai/DASH/dash-pipeline/SAI/utils/p4ir/p4ir_var_ref_graph.py", line 28, in __build_counter_list
08:46:42      self.ir.walk(
08:46:42    File "dash-sai/DASH/dash-pipeline/SAI/utils/p4ir/p4ir_tree.py", line 18, in walk
08:46:42      on_match(match)
08:46:42    File "dash-sai/DASH/dash-pipeline/SAI/utils/p4ir/p4ir_var_ref_graph.py", line 24, in on_counter_definition
08:46:42      ir_value = P4IRVarInfo.from_ir(match.value)
08:46:42                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
08:46:42    File "dash-sai/DASH/dash-pipeline/SAI/utils/p4ir/p4ir_var_info.py", line 11, in from_ir
08:46:42      ir_def_node["Source_Info"]["source_fragment"],
08:46:42      ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
08:46:42  TypeError: list indices must be integers or slices, not str
Lingua principale
Python
Stelle
103
Fork
109
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 sonic-net/DASH

Tutte le issue di sonic-net/DASH

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.