feat(core): add start_time and end_time query params on audit log routes#8806
Merged
simeng-li merged 1 commit intoMay 15, 2026
Conversation
COMPARE TO
|
| Name | Diff |
|---|---|
| .changeset/logs-time-window.md | 📈 +731 Bytes |
| packages/core/src/queries/log.ts | 📈 +443 Bytes |
| packages/core/src/routes/hook.test.ts | 📈 +2.55 KB |
| packages/core/src/routes/hook.ts | 📈 +751 Bytes |
| packages/core/src/routes/hooks.openapi.json | 📈 +820 Bytes |
| packages/core/src/routes/log.openapi.json | 📈 +789 Bytes |
| packages/core/src/routes/log.test.ts | 📈 +2.24 KB |
| packages/core/src/routes/log.ts | 📈 +461 Bytes |
| packages/core/src/utils/time-window.ts | 📈 +968 Bytes |
| packages/integration-tests/src/tests/api/audit-logs/time-window.test.ts | 📈 +5.78 KB |
| packages/phrases/src/locales/ar/errors/log.ts | 📈 +79 Bytes |
| packages/phrases/src/locales/de/errors/log.ts | 📈 +68 Bytes |
| packages/phrases/src/locales/en/errors/log.ts | 📈 +65 Bytes |
| packages/phrases/src/locales/es/errors/log.ts | 📈 +72 Bytes |
| packages/phrases/src/locales/fr/errors/log.ts | 📈 +77 Bytes |
| packages/phrases/src/locales/it/errors/log.ts | 📈 +76 Bytes |
| packages/phrases/src/locales/ja/errors/log.ts | 📈 +97 Bytes |
| packages/phrases/src/locales/ko/errors/log.ts | 📈 +74 Bytes |
| packages/phrases/src/locales/pl-pl/errors/log.ts | 📈 +79 Bytes |
| packages/phrases/src/locales/pt-br/errors/log.ts | 📈 +72 Bytes |
| packages/phrases/src/locales/pt-pt/errors/log.ts | 📈 +72 Bytes |
| packages/phrases/src/locales/ru/errors/log.ts | 📈 +92 Bytes |
| packages/phrases/src/locales/th/errors/log.ts | 📈 +87 Bytes |
| packages/phrases/src/locales/tr-tr/errors/log.ts | 📈 +74 Bytes |
| packages/phrases/src/locales/zh-cn/errors/log.ts | 📈 +66 Bytes |
| packages/phrases/src/locales/zh-hk/errors/log.ts | 📈 +66 Bytes |
| packages/phrases/src/locales/zh-tw/errors/log.ts | 📈 +66 Bytes |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds optional start_time and end_time (unix-ms) query parameters to the audit log list endpoints to allow callers to restrict the queried time window, reducing scan cost and enabling Console time-range filtering.
Changes:
- Extend log query building to support exclusive
createdAtbounds (startTime/endTime) and wire these through/api/logsand/api/hooks/{id}/recent-logs. - Add shared parsing/validation helpers (
parseTimestampParam,validateTimeWindow) and surface400responses for invalid windows / non-finite timestamps. - Update OpenAPI docs, add the new
log.invalid_time_windowi18n key across locales, and add unit + integration coverage for the new params.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/core/src/queries/log.ts |
Adds startTime/endTime to LogCondition and emits SQL predicates for the bounds. |
packages/core/src/utils/time-window.ts |
New shared query-param parsing + time-window validation utilities. |
packages/core/src/routes/log.ts |
Accepts start_time/end_time on GET /logs and forwards parsed bounds to queries. |
packages/core/src/routes/hook.ts |
Accepts start_time/end_time on GET /hooks/:id/recent-logs, preserving 24h default only when no bounds provided. |
packages/core/src/routes/log.test.ts |
Unit tests covering param pass-through and 400 validation cases for /logs. |
packages/core/src/routes/hook.test.ts |
Unit tests covering default-vs-explicit-window behavior and validation for /recent-logs. |
packages/integration-tests/src/tests/api/audit-logs/time-window.test.ts |
Integration coverage for filtering behavior and validation responses on GET /api/logs. |
packages/core/src/routes/log.openapi.json |
Documents new query params and 400 response for /api/logs. |
packages/core/src/routes/hooks.openapi.json |
Documents new query params, 400 response, and the “replaces 24h default” behavior for /recent-logs. |
packages/phrases/src/locales/*/errors/log.ts |
Adds localized log.invalid_time_window error message. |
.changeset/logs-time-window.md |
Announces the new query params and semantics in release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1700915 to
149c016
Compare
90c14b4 to
f0e5aa7
Compare
4 tasks
f0e5aa7 to
1da6d12
Compare
149c016 to
1c81ceb
Compare
1da6d12 to
b89ff21
Compare
b89ff21 to
30493f9
Compare
gao-sun
approved these changes
May 14, 2026
Base automatically changed from
simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is
to
master
May 14, 2026 03:18
30493f9 to
94d9c26
Compare
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes LOG-13418. Stacked on #8802.
Adds optional
start_timeandend_timeunix-ms query parameters toGET /api/logsandGET /api/hooks/:id/recent-logs, letting callers narrow the time window so the count scan is cheaper and so the Console can build a time-range picker on top.What changed
packages/core/src/queries/log.ts—LogConditiongainsstartTime/endTime(exclusive, in unix-ms).buildLogConditionSqlemits a symmetricto_timestamp(value::double precision / 1000)clause for each bound.packages/core/src/utils/time-window.ts(new) — sharedparseTimestampParam(throws 400guard.invalid_inputon non-finite input) andvalidateTimeWindow(throws 400log.invalid_time_windowwhen both bounds are present andstart >= end).packages/core/src/routes/log.ts— accepts both params, declares 400 inkoaGuard.status.packages/core/src/routes/hook.ts— same wiring, preserving the historical 24-hour lower bound only when neither param is supplied (hasExplicitWindowflag). Any explicit bound replaces the default, so callers stay in control.log.invalid_time_windowadded to all 17 locales (the route declares 400 explicitly becausekoaGuardonly auto-bypasses status assertion forguard.*codes).Expected behavior
createdAtstrictly between the bounds (>/<); webhook endpoint drops its 24h default.start_time >= end_time(including equal) or non-finite values → 400 withlog.invalid_time_window/guard.invalid_input.Reviewer notes
/hooks/:id/recent-logsis intentional and exhaustively covered by unit tests across all four combinations (none / start-only / end-only / both).Testing
Unit tests, integration tests
Checklist
.changeset