engram: fix silently-wrong query params, and make el_seed.o + el_runtime.o link
El SDK CI - dev / build-and-test (pull_request) Failing after 14m49s
El SDK CI - dev / build-and-test (pull_request) Failing after 14m49s
Three real bugs, all found by actually running the thing rather than reading it.
1. query_param never URL-decoded. A GET of /api/search?q=neural%20network
searched for the literal string "neural%20network" and returned []. Every
multi-word search against the live engram has been silently returning empty
results — not an error, an empty result, which is why it went unnoticed.
Affects every GET route that reads query params, not just search.
2. query_param matched key names unanchored. str_index_of(qs, "q=") matches
inside "faq=", so "?faq=X&q=Y" returned X for key "q". Verified live before
the fix. Now searches for "&key=" against "&"+querystring so a match can
only land on a real parameter boundary.
3. el_request_start/el_request_end were defined in BOTH el_seed.c and
el_runtime.c, so linking the two objects together — which is exactly what
the product build does — failed with duplicate symbols. el_seed.c's own
comment already says these moved there ("formerly defined in el_runtime.c.
Now self-contained in el_seed.c"); the el_runtime.c copies were left behind
during that move. Removed them, kept declarations since http_worker calls
them. Also added the three missing prototypes (engram_op_assert_json,
engram_node_full_in, engram_connect_in) that el_seed.c wraps but never
declared, which made it fail to compile standalone under C99+.
Verified: engram builds and links clean from canonical source; before/after
comparison on a copy of the real store shows "neural network" returning a real
match where the live build returns [], and "?faq=WRONG&q=MetaColloc" now
resolving to MetaColloc. Live engram on :8742 was never touched.
This commit is contained in:
@@ -105,23 +105,14 @@ static void el_arena_track(char* p) {
|
||||
_tl_arena.ptrs[_tl_arena.count++] = p;
|
||||
}
|
||||
|
||||
/* Called by http_worker before dispatching the El handler. */
|
||||
void el_request_start(void) {
|
||||
_tl_arena.count = 0;
|
||||
_tl_arena_active = 1;
|
||||
_tl_fs_read_len = 0; /* never let a previous request's file length */
|
||||
_tl_fs_read_buf = NULL; /* leak into this response's byte accounting */
|
||||
}
|
||||
|
||||
/* Called by http_worker after the El handler returns and the response is sent.
|
||||
* Frees every intermediate string allocated during the request. */
|
||||
void el_request_end(void) {
|
||||
_tl_arena_active = 0;
|
||||
for (size_t i = 0; i < _tl_arena.count; i++) {
|
||||
free(_tl_arena.ptrs[i]);
|
||||
}
|
||||
_tl_arena.count = 0;
|
||||
}
|
||||
/* el_request_start / el_request_end moved to el_seed.c (see its comment at the
|
||||
* definition: "formerly defined in el_runtime.c. Now self-contained in
|
||||
* el_seed.c, delegating to the seed arena."). The copies here were left behind
|
||||
* during that move and made el_seed.o + el_runtime.o fail to link together with
|
||||
* duplicate symbols — which is exactly the link the real product build does.
|
||||
* Declared (not defined) here: el_runtime.c's http_worker still calls them. */
|
||||
void el_request_start(void);
|
||||
void el_request_end(void);
|
||||
|
||||
/* ── Scoped arena for CLI use ─────────────────────────────────────────────── *
|
||||
* CLI programs never call el_request_start/end, so all strdup allocations are
|
||||
|
||||
Reference in New Issue
Block a user