trace: the cursor readers crash on a JSON line that is not an object
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Aptitud para principiantes
- 25/100
Línea de trabajo
Start with the spool loop and cursor_events_to_claude in tokeneconomizer/trace/cursor.py, then compare their JSON handling with the existing guarded transcript loop. The issue describes the regression cases and says a regression test is ready; done means both readers skip valid JSON values that are not objects and preserve the other records. A linked pull request, #181, is already open.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What happens
cursor_events_to_claude and cursor_prompt_count (tokeneconomizer/trace/cursor.py) parse each line with json.loads and then call .get on the result, without the isinstance(ev, dict) check. A line that is valid JSON but not an object (null, 42, "text", [1, 2]) has no .get, so both readers raise AttributeError and one such line discards the whole session's trace.
#150 added that check to the 13 readers that missed it. cursor.py's two were not in that sweep — they came with the #149 headless work (the recorded-event spool and the agent_transcript fallback). The opencode, Claude, Codex and Copilot readers all have the check.
Repro
events.jsonl:
null
[1, 2]
{"hook_event_name": "UserPromptSubmit", "prompt": "hi"}
"str"
{"hook_event_name": "PostToolUse", "tool_use_id": "t1", "tool_name": "Shell", "tool_input": {"command": "pytest"}, "tool_response": {"content": "3 passed", "exit_code": 0}}
>>> from tokeneconomizer import trace
>>> trace.cursor_prompt_count("events.jsonl")
AttributeError: 'NoneType' object has no attribute 'get'
>>> trace.cursor_events_to_claude("events.jsonl", "out.jsonl")
AttributeError: 'NoneType' object has no attribute 'get'
Both lose every record in the file, not just the bad line. The prompt-count fallback loop over Cursor's own transcript (second loop) already has the isinstance(row, dict) guard; it is the spool loop and cursor_events_to_claude that miss it.
Impact
Cursor.prompt_count and the mechanism trace conversion abort mid-session. In a hook the fail-open rule turns the exception into {} plus an errors.log line, and the fold keeps the session pending and retries the same crash at the next session start — the same failure shape #150 fixed for the other readers.
Fix
The same one-line guard after json.loads in both places. I have it with a regression test ready and will open the PR.
- Lenguaje dominante
- Python
- Estrellas
- 5.6k
- Forks
- 344
- Merge medio
- 14 h 41 min
- PR fusionados (30 d)
- 54
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/TokenEconomizer
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
microsoft/TokenEconomizer#193 ·
Los mantenedores suelen responder en 1 día
-
pricing: Claude's 1-hour cache writes are priced at 1.25x, but billed at 2xPosiblemente ocupada @anascherif la tomó hoy. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 25/100
microsoft/TokenEconomizer#191 ·
Los mantenedores suelen responder en 1 día
-
trace: Claude Code's `<synthetic>` notices count as requests and can make a Claude session price on the fallback curvePosiblemente ocupada @1AbdullahButt la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 20/100
microsoft/TokenEconomizer#189 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
microsoft/TokenEconomizer#186 ·
Los mantenedores suelen responder en 1 día
-
plugin: the agent-output readers crash on a JSON line that is not an objectPosiblemente ocupada @rahul05ranjan la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 25/100
microsoft/TokenEconomizer#182 ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/TokenEconomizer
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Treat corrupt-shape state files as missing in `load_state`Posiblemente ocupada @Qrytics la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
OvertureMaps/overturemaps-py#175 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
awslabs/visual-asset-management-system#1278 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
aws-samples/sample-per-model-bedrock#835 ·
Los mantenedores suelen responder en 1 día