Skip to content

update: context api support for start and end time#1695

Merged
nikhilsinhaparseable merged 1 commit into
parseablehq:mainfrom
nikhilsinhaparseable:context-api-ts
Jun 23, 2026
Merged

update: context api support for start and end time#1695
nikhilsinhaparseable merged 1 commit into
parseablehq:mainfrom
nikhilsinhaparseable:context-api-ts

Conversation

@nikhilsinhaparseable

@nikhilsinhaparseable nikhilsinhaparseable commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

context api request to have support to send either of -

  1. context window (1m, 5m, 10m etc)
  2. context start and end time

add validations -

  1. p_timestamp of the reference log should be within the context window
  2. window and start/end time - both should not be present in the request
  3. start <= end time

Summary by CodeRabbit

  • New Features

    • Added optional contextStartTime and contextEndTime fields for flexible time-bound configuration
    • contextWindow field is now optional
  • Bug Fixes

    • Enhanced timestamp validation with clearer error messages
    • Enforced mutual exclusivity between window-based and explicit time range modes

context api request to have support to send either of -
1. context window (1m, 5m, 10m etc)
2. context start and end time

add validations -
1. p_timestamp of the reference log should be within the context window
2. window and start/end time - both should not be present in the request
3. start <= end time
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8b5edff3-2918-4236-a7c3-3d3e496c85c4

📥 Commits

Reviewing files that changed from the base of the PR and between c849704 and 759b959.

📒 Files selected for processing (1)
  • src/handlers/http/query_context.rs

Walkthrough

LogContextRequest gains optional contextStartTime and contextEndTime fields while making contextWindow optional. A new resolve_log_context_bounds resolver enforces mutual exclusivity between the window mode and the explicit start/end mode. Timestamp parsing is centralized, anchor-in-bounds validation is added, and time formatting switches to SecondsFormat::AutoSi.

Changes

LogContextRequest explicit time bounds

Layer / File(s) Summary
LogContextRequest shape and handler wiring
src/handlers/http/query_context.rs
contextWindow changed to Option<String>; contextStartTime and contextEndTime added as optional fields. query_context handler updated to call resolve_log_context_bounds and validate the anchor timestamp within the resolved bounds.
Bounds resolver, explicit bounds parsing, and anchor validation
src/handlers/http/query_context.rs
resolve_log_context_bounds enforces mutual exclusivity between window and explicit start/end modes. log_context_explicit_bounds parses and validates timestamp ordering. validate_log_context_anchor_in_bounds checks pTimestamp ∈ [start, end). parse_log_context_timestamp refactored to delegate to a generic parse_log_context_time_field with field-specific error messages. format_log_context_api_time switches to SecondsFormat::AutoSi.
Unit test updates
src/handlers/http/query_context.rs
Tests added/updated to cover explicit bounds acceptance, log_context_window_bounds expectations, resolver one-mode-only validation, anchor-in-bounds enforcement, and SQL expectations using log_context_explicit_bounds.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • parseablehq/parseable#1687: Introduced the query_context handler and LogContextRequest types that this PR directly modifies to support explicit time bounds.

Suggested reviewers

  • parmesant

Poem

🐇 Hop hop, the window's now optional, you see,
Start time and end time set context bounds free,
The resolver enforces: pick one mode, not two,
The anchor must fit in the range that you choose,
AutoSi ticks the seconds with glee,
One bounding bunny, as precise as can be! 🕐

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description covers the core functionality changes and validation rules but lacks testing confirmation, code comments documentation, and feature documentation as specified in the template. Complete the PR template checklist by confirming testing completion, documenting code comments explaining the 'why', and adding user-facing documentation for the new feature.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding start and end time support to the context API alongside the existing window parameter.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@nikhilsinhaparseable nikhilsinhaparseable merged commit 595af02 into parseablehq:main Jun 23, 2026
12 checks passed
ygndotgg pushed a commit to ygndotgg/parseable that referenced this pull request Jun 23, 2026
context api request to have support to send either of -
1. context window (1m, 5m, 10m etc)
2. context start and end time

add validations -
1. p_timestamp of the reference log should be within the context window
2. window and start/end time - both should not be present in the request
3. start <= end time
parmesant pushed a commit to parmesant/parseable that referenced this pull request Jun 24, 2026
context api request to have support to send either of -
1. context window (1m, 5m, 10m etc)
2. context start and end time

add validations -
1. p_timestamp of the reference log should be within the context window
2. window and start/end time - both should not be present in the request
3. start <= end time
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