styling: no runtime validation of column configs — unknown displayer or color_rule fails silently in the browser

Abierto
#976 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
49/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, typescript
Área
data, frontend

Línea de trabajo

Start with style_columns and the TypedDicts in styling_core.py:60-158, then trace the supported names through Displayer.ts:302 and Styler.tsx:163. Check how the column config and dataframe are available during styling. Done means invalid names or missing referenced columns fall back to the parent style, with tests covering those cases and how Python and TypeScript name lists stay aligned.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Problem

A styling class can return a column config that is structurally a dict, passes every Python check, and is still wrong: a displayer name that no JS displayer implements, a color_rule that getStyler doesn't handle, or a val_column / exist_column naming a column that isn't in the frame. Nothing validates it on the way out. The TypedDicts in styling_core.py:60-158 are annotations only — no runtime check — and the TS types on the other side (DFWhole.ts:176) are erased at build time.

The failure is then silent or misleading:

  • unknown displayer: getBaseFormatter (Displayer.ts:302) falls through to default: and formats the column as a string, so a numeric column silently loses its formatting.
  • unknown color_rule: getStyler (Styler.tsx:163) has no default branch and returns undefined, so the column just isn't colored.
  • val_column / exist_column pointing at a missing column: the rule runs against data that isn't there.

The MRO fallback added in #968 doesn't help with any of these, because nothing raises. #971 (reporting styling exceptions) doesn't either, for the same reason.

Impact

This is the remaining hole in "a user's styling subclass can't break the table." Exceptions are handled; configs that are well-formed but meaningless are not. The typo cases ('flaot', 'color_statik') are the common ones, and they present as "my formatting/color setting doesn't do anything" with nothing in the logs.

Suggested fix

Validate each column config in style_columns after it's built, before it goes on the wire:

  • displayer_args['displayer'] is one of the known displayer names.
  • color_map_config['color_rule'] is one of the rules getStyler implements.
  • any val_column / exist_column exists in the frame (style_columns already has df).

A failed check should be treated like an exception from style_column: fall back to the parent class for that column, and, once #971 lands, record the reason on the column so it's visible in the UI.

Keeping the name lists in sync between Python and TS is the part worth thinking about — one generated list, or a test that asserts the Python literals match the switch cases in Displayer.ts / Styler.tsx.

Context

Came out of reviewing #968. Related: #966 (headers lost on a styling exception, fixed in #968), #971 (surface styling exceptions in the column config).

Lenguaje dominante
Python
Estrellas
685
Forks
17
Merge medio
21 h 7 min
PR fusionados (30 d)
19

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de buckaroo-data/buckaroo

Todos los issues de buckaroo-data/buckaroo

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.