Skip to content

refactor: split uteke-server monolith into modules (#514) - #516

Merged
ajianaz merged 3 commits into
developfrom
refactor/server-modular-issue-514
Jul 1, 2026
Merged

ajianaz merged 3 commits into
developfrom
refactor/server-modular-issue-514

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator

Splits 1,840-line main.rs into 4 files: types.rs (282), context.rs (262), handlers.rs (863), main.rs (467). Zero behavior change. Closes #514.

v0.6.3 rebase: Rebased onto latest develop (includes Docker trixie-slim fix). Fixed clippy (unused Cursor import) and rustfmt.

@github-actions

github-actions Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (3)

  • crates/uteke-server/src/handlers.rs:625 — The /mcp handler checks Content-Length and then reads the body with req.as_reader().take(MAX_MCP_BODY).read_to_string(&mut body), but it never verifies whether the stream actually exceeded MAX_MCP_BODY. If a client omits or understates Content-Length, take(MAX_MCP_BODY) truncates the input silently and the handler proceeds with a partial JSON-RPC payload instead of rejecting it as too large. This differs from read_body() in types.rs, which reads MAX_PAYLOAD_SIZE + 1 bytes and explicitly errors when the limit is exceeded.
  • crates/uteke-server/src/handlers.rs:331 — The new /forget branch builds params by splitting the raw query string and storing kv.next()?.to_string() / kv.next()?.to_string() directly. Unlike the extracted helper parse_query_param() in types.rs, this path does not call url_decode(). As a result, requests like /forget?tag=my%20tag&namespace=foo%2Fbar will pass encoded values to bulk_forget_by_tag, changing behavior from the shared helpers already used elsewhere in this diff.
  • crates/uteke-server/src/handlers.rs:359 — The GET /stats handler parses the query string manually into a HashMap<String, String> and reads namespace from it without decoding. This means a request like /stats?namespace=my%20space will pass my%20space to uteke.stats() instead of my space. The extracted helpers in types.rs already provide parse_query_param()/url_decode() for this exact purpose, so the current implementation is inconsistent and can break namespaces containing reserved characters.

Review powered by cora-cli · BYOK · MIT

ajianaz added 3 commits July 2, 2026 00:02
Split 1,840-line main.rs into 4 focused files:
- types.rs: request/response structs, helpers, constants
- context.rs: ReqCtx, auth, CORS middleware
- handlers.rs: route() dispatcher (all endpoint logic)
- main.rs: CLI args, config loading, server startup

Zero behavior change. All endpoints return identical responses.
Closes #514
- handlers.rs: add serde::Deserialize for local struct derives
- main.rs: add tiny_http::Server, remove unused Cursor import
- main.rs: use imported Server instead of tiny_http::Server::http
- types.rs: remove unused Cursor import (clippy error)
- context.rs: rustfmt function signature wrapping
- main.rs: rustfmt module declaration order + trailing comma
@ajianaz
ajianaz force-pushed the refactor/server-modular-issue-514 branch from ea8df42 to a4330ed Compare July 1, 2026 17:02
}
},
None => uteke.list(
req_data.tag.as_deref(),
})
.collect();

if let Some(id) = params.get("id") {
match uteke.delete_room(&room_id) {
Ok(()) => ctx.ok_response_for(req, &serde_json::json!({"deleted": room_id})),
Err(e) => {
let msg = format!("{e}");
@ajianaz
ajianaz merged commit 77931f2 into develop Jul 1, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the refactor/server-modular-issue-514 branch July 1, 2026 17:09
ajianaz added a commit that referenced this pull request Aug 13, 2026
…e-514

refactor: split uteke-server monolith into modules (#514)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: split uteke-server monolith (1,840 lines) into modules

2 participants