[Feature]: expand expression evaluator filter set (upper, lower, length, split, sort, to_json)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 52/100
Línea de trabajo
Start in src/specify_cli/workflows/expressions.py, reading the existing filter registration and _apply_filter() implementation around lines 20-26 and 419-484. Then inspect tests/test_workflows.py and the existing filter tests to understand input and error conventions. The work is done when the agreed filter set is registered, implemented, and covered by tests, including the unresolved length semantics and naming decisions.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
The workflow expression evaluator currently supports only 5 filters: default, join, map, contains, and from_json. For a system marketed as "Jinja2-like," common string and collection operations are missing, forcing workflow authors to shell out for basic transformations.
Missing filters that workflow authors frequently need:
- String operations:
upper,lower,trim(whitespace),split(string to list) - Collection operations:
length,first,last,sort,unique - Serialization:
to_json(the reverse of existingfrom_json)
Example of current limitation:
# Cannot do this today — no `length` filter:
- id: check
type: shell
config:
command: "echo 'Found {{ items | length }} files'"
# Cannot do this today — no `split` filter:
- id: list
type: shell
config:
command: "echo '{{ file_list | split(\",\") | length }} files found'"
Proposed Solution
Add a batch of new filters to the expression evaluator, following the existing registration pattern.
String Filters
| Filter | Input | Output | Example |
|---|---|---|---|
upper |
"hello" |
"HELLO" |
{{ name | upper }} |
lower |
"HELLO" |
"hello" |
{{ name | lower }} |
trim |
" hi " |
"hi" |
{{ name | trim }} |
split |
"a,b,c" |
["a","b","c"] |
{{ csv | split(",") }} |
Collection Filters
| Filter | Input | Output | Example |
|---|---|---|---|
length |
["a","b"] |
2 |
{{ items | length }} |
first |
["a","b","c"] |
"a" |
{{ items | first }} |
last |
["a","b","c"] |
"c" |
{{ items | last }} |
sort |
[3,1,2] |
[1,2,3] |
{{ items | sort }} |
unique |
["a","a","b"] |
["a","b"] |
{{ items | unique }} |
Serialization Filter
| Filter | Input | Output | Example |
|---|---|---|---|
to_json |
{"key":"val"} |
"{\"key\":\"val\"}" |
{{ data | to_json }} |
Design Notes
- Follows existing pattern: Each filter is a standalone function registered in
_REGISTERED_FILTERSand dispatched in_apply_filter()(expressions.py lines 20-26, 419-484) - Safe by design: All operations are pure transformations — no arbitrary code execution, no side effects, consistent with the sandboxed evaluator model
lengthenables conditionals: Unlocks{% if items | length > 0 %}patterns that currently require shell workaroundssplitbridges shell output: Shell steps return newline/comma-separated strings;splitconverts them to lists for downstream processingto_jsoncompletes the round-trip:from_jsonexists;to_jsonis its natural pair for passing structured data back to shell commands
Affected Files
src/specify_cli/workflows/expressions.py— filter registration and implementation (lines 20-26, 419-484)tests/test_workflows.py— unit tests for each new filter
Questions
- Are there additional filters you would want in this batch, or should we start with a smaller set?
- Should
lengthwork on both lists and strings (Jinja2 behavior), or only collections? - Any naming preferences (e.g.,
lenvslength,flattenvsunique)?
Happy to implement if this aligns with your plans for the expression engine.
- Lenguaje dominante
- Python
- Estrellas
- 138k
- Forks
- 12.4k
- Merge medio
- 3 d 6 h
- PR fusionados (30 d)
- 145
Guía de contribución
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 github/spec-kit
-
enhancement needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
enhancement needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
enhancement needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
enhancement needs-triage triage-can-wait
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Todos los issues de github/spec-kit
Issues similares
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
canonical/paas-charm#368 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
tech debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
addition to tracking list Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
StevenBlack/hosts#3256 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
qualcomm/qai-appbuilder#275 ·