Refactor: split the 1161-line functions.rs god-file into topical submodules
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Start with src/webserver/database/sqlpage_functions/functions.rs and the existing SQL function tests; read the short README requested for sqlpage_functions/ and inspect how the current macro registry discovers functions. The issue proposes one function per file plus removal of duplicated fetch pipelines, so confirm the discovery convention and scope before moving implementations. Done means topical modules are registered and existing function and end-to-end tests pass without behavior changes.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Split functions.rs into one file per function
src/webserver/database/sqlpage_functions/functions.rs is a 1161-line god-file with no internal boundaries. It is one of the most-churned files in the DB module, and it mixes the registry of every built-in SQL function with ~40 unrelated implementations: HTTP fetch, password hashing, file persistence, regex, HMAC, OIDC claim extraction, subprocess exec, and the recursive run_sql engine entry point. Navigation is by scrolling, security-sensitive code sits next to unrelated helpers, and unit tests are interleaved with implementations.
$ wc -l src/webserver/database/sqlpage_functions/functions.rs
1161 src/webserver/database/sqlpage_functions/functions.rs
This splits out the refactor item from #1249 into a concrete, actionable issue.
Why this matters
Unrelated and security-sensitive concerns are interleaved in a single file, which raises cognitive load and regression risk on a file that changes often:
- Subprocess
execsits a few lines from the HTTP request builders,run_sql(the recursive engine entry point) is in the same flat file ashash_passwordandhmac. - Unit tests are scattered between implementations rather than grouped, e.g.
test_random_string,test_hash_password,test_hmac. - The duplicated HTTP fetch pipelines flagged in #1249 are still present:
fetchandfetch_with_metarepeat the same tracing span setup, client creation, request build, and body preparation. Two copies of this pipeline is a drift hazard (a fix to one, like the body-log redaction in #1249, can silently miss the other). - The OIDC
user_infoclaim resolver is a long hand-maintained 30+ armmatchover claim names that has no business living next to subprocess and SQL execution code.
Proposed change
Split the implementations into topical submodules under sqlpage_functions/.
At compile time, iterate of files in the sqlpage_functions folder and generate one function per file. Use convention over configuration, adding a new file in the folder is all that should be needed to create a new sqlpage function.
The short readme in sqlpage_functions should explain the mechanism.
Risks and mitigations
Low risk; this is a mechanical move with no behavior change.
- The macro registry keeps wiring centralized, so the public function surface does not change.
- Move implementations file-by-file, one module at a time, each a self-contained reviewable commit.
- Existing function tests (the interleaved
test_*plus the end-to-end SQL function tests) pin behavior across the move.
Expected win
Better navigability and reviewability of a frequently-edited file, security-sensitive exec/run_sql isolated and easy to audit, and removing the fetch/fetch_with_meta duplication eliminates a drift hazard.
Refs #1249 (item 6).
- Vorherrschende Sprache
- Rust
- Sterne
- 2.6k
- Forks
- 175
- Ø Merge
- 14 Std. 16 Min.
- Gemergte PRs (30 T.)
- 43
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus sqlpage/SQLPage
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
sqlpage/SQLPage#1218 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
There is no convenient way to reproduce issuesEvtl. vergeben @81reap hat das vor 26 Tagen übernommen. Offenenhancement
sqlpage/SQLPage#1566 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Confusing sort interfaceEvtl. vergeben @lovasoa hat das vor 74 Tagen übernommen. Offenbug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 20/100
sqlpage/SQLPage#1442 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Mutation Testing Results :: Dead Code + Missing TestsEvtl. wieder frei @81reap hat das vor 61 Tagen übernommen, und es ist kein Pull Request offen. Offen
sqlpage/SQLPage#1396 · 5 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in sqlpage/SQLPage
Ähnliche Issues
-
CI/CD ignore-for-release
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
eclipse-ankaios/ankaios#844 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
std: `SliceIndex<str>` missing for `std::ops` ranges, so generic `R: SliceIndex<str>` bounds failOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
symposium-dev/symposium#530 ·
Maintainer antworten meist innerhalb von 5 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag