Skip to content

feat(#404): configurable limits — env vars + config section - #419

Merged
ajianaz merged 1 commit into
developfrom
feat/404-configurable-limits
Jun 21, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/404-configurable-limits

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements #404.

Changes

Test

  • ✅ 283 unit tests passed
  • ✅ Clippy clean
  • ✅ Fmt clean

Milestone: v0.3.0 — Graph RAG
Unblocks: #406 (document engine)

Move hardcoded constants to configurable values:

- MAX_CONTENT_LENGTH: 10,000 → 100,000 (10x). Document engine needs
  larger content support. Set to 0 to disable entirely.
- MAX_PAYLOAD_SIZE: 1MB → 10MB (for document uploads).
- Added LimitsConfig struct with env var overrides:
  UTEKE_MAX_CONTENT_LENGTH, UTEKE_MAX_TAGS_COUNT, UTEKE_MAX_TAG_LENGTH,
  UTEKE_MAX_PAYLOAD_SIZE, UTEKE_DEFAULT_RECALL_LIMIT
- Added [limits] section to default config template
- Added validate_input_with_limits() for custom limit validation
- Original validate_input() now delegates with default constants

Blocks #406 (document engine).

/// Migrate legacy `~/.uteke/config.toml` → `~/.uteke/uteke.toml`.
/// Read an env var as a type T, falling back to default if unset or invalid.
fn env_or<T: std::str::FromStr>(key: &str, default: T) -> T {

/// Validate input with configurable limits (#404).
/// Set max_content_length to 0 to disable content length check.
pub fn validate_input_with_limits(
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (2)

  • crates/uteke-core/src/lib.rs:82 — The new configurable validation still uses content.len() and t.len() to enforce max_content_length and max_tag_length, but both the field docs in LimitsConfig and the error messages describe these limits as being in characters. In Rust, str::len() counts UTF-8 bytes, so multibyte text like emoji or non-ASCII characters will be rejected earlier than configured. This creates incorrect behavior for any user relying on the documented character-based limits.
  • crates/uteke-cli/src/config.rs:677 — The new env_or helper returns the fallback whenever parsing fails: std::env::var(key).ok().and_then(|v| v.parse().ok()).unwrap_or(default). This means malformed values like UTEKE_MAX_TAGS_COUNT=abc or an out-of-range integer are accepted without any warning, and the process quietly uses defaults instead. Because these settings control input and payload limits, silently ignoring invalid overrides makes misconfiguration hard to detect and can leave operators thinking protections are active when they are not.

Review powered by cora-cli · BYOK · MIT

@ajianaz
ajianaz merged commit c0a70db into develop Jun 21, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the feat/404-configurable-limits branch June 21, 2026 12:31
ajianaz added a commit that referenced this pull request Aug 13, 2026
Move hardcoded constants to configurable values:

- MAX_CONTENT_LENGTH: 10,000 → 100,000 (10x). Document engine needs
  larger content support. Set to 0 to disable entirely.
- MAX_PAYLOAD_SIZE: 1MB → 10MB (for document uploads).
- Added LimitsConfig struct with env var overrides:
  UTEKE_MAX_CONTENT_LENGTH, UTEKE_MAX_TAGS_COUNT, UTEKE_MAX_TAG_LENGTH,
  UTEKE_MAX_PAYLOAD_SIZE, UTEKE_DEFAULT_RECALL_LIMIT
- Added [limits] section to default config template
- Added validate_input_with_limits() for custom limit validation
- Original validate_input() now delegates with default constants

Blocks #406 (document engine).
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.

2 participants