Skip to content

Conversation

@davemarco
Copy link
Contributor

@davemarco davemarco commented Jul 3, 2025

This PR is dependent on #1027, #1028 being merged

Description

PR moves extract stream route and plugin into new fastify architecture. This is a chain of PRs which started with #1027

There was alot of duplication between the plugin that submitted search jobs, and the old extract stream plugin (they both submit jobs to the same mysql database), so i completely refactored so they share more code. As a result, the PR is not trivial.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

tested streams with clp and clp-s

Summary by CodeRabbit

  • New Features

    • Added backend support and API route for stream file extraction with metadata retrieval.
    • Introduced schema validation for stream file extraction requests.
  • Refactor

    • Consolidated job management into a unified query job manager for search, aggregation, and stream extraction.
    • Updated API routes and server plugins to use new job management classes and removed legacy database plugins.
    • Simplified server setup by removing old database-related routes and plugins.
  • Bug Fixes

    • Enhanced validation and error handling for stream extraction jobs and metadata queries.
  • Chores

    • Removed deprecated backend files, types, and utilities related to prior database and job management systems.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 3, 2025

Walkthrough

This change refactors the server-side handling of stream file extraction and query job management by replacing the legacy DbManager and QueryJobsDbManager classes with new StreamFileManager and QueryJobDbManager plugins. It introduces new API routes, schemas, and typings for stream file operations, and updates client and proxy configurations accordingly.

Changes

Files/Groups Change Summary
components/webui/client/src/api/stream-files/index.ts, .../ui/QueryStatus.tsx Updated API endpoint and import path for stream file extraction job submission.
components/webui/client/vite.config.ts Removed proxy entry for /query/ and updated related comments.
components/webui/server/src/app.ts, .../src/plugins/DbManager.ts, .../routes/query.ts, .../src/typings/DbManager.ts, .../src/utils/time.ts Removed legacy database manager, extraction route, and related typings/utilities. Simplified app plugin options.
components/webui/server/src/fastify-v2/app.ts Stopped passing DB credentials to FastifyV1App; simplified plugin registration.
components/webui/server/src/fastify-v2/plugins/app/QueryJobDbManager/index.ts, .../typings.ts Added new unified query job manager plugin and poll interval constant.
components/webui/server/src/fastify-v2/plugins/app/StreamFileManager.ts Added new stream file manager plugin for extraction and metadata retrieval.
components/webui/server/src/fastify-v2/plugins/app/search/QueryJobsDbManager/index.ts, .../typings.ts Removed old query jobs DB manager and its polling constant.
components/webui/server/src/fastify-v2/routes/api/search/index.ts, .../typings.ts, .../utils.ts Updated to use new query job manager, unified job submission/cancellation, and renamed parameters.
components/webui/server/src/fastify-v2/routes/api/stream-files/index.ts Introduced new API route for stream file extraction using new managers and schema.
components/webui/server/src/fastify-v2/schemas/stream-files.ts Added new TypeBox schema for stream file extraction requests.
components/webui/server/src/typings/stream-files.ts Added typings for stream file metadata and MongoDB collection.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API_Route as /api/stream-files/extract
    participant StreamFileManager
    participant QueryJobDbManager
    participant MongoDB
    participant S3Manager

    Client->>API_Route: POST extract (dataset, extractJobType, logEventIdx, streamId)
    API_Route->>StreamFileManager: getExtractedStreamFileMetadata(streamId, logEventIdx)
    StreamFileManager->>MongoDB: Find stream file metadata
    alt Metadata Found
        StreamFileManager-->>API_Route: Return metadata
    else Metadata Not Found
        StreamFileManager->>QueryJobDbManager: submitAndWaitForExtractStreamJob(...)
        QueryJobDbManager->>MySQL: Insert job, poll for completion
        QueryJobDbManager-->>StreamFileManager: Job complete
        StreamFileManager->>MongoDB: Find stream file metadata
        StreamFileManager-->>API_Route: Return metadata or null
    end
    alt S3Manager available
        API_Route->>S3Manager: getPresignedUrl(path)
        S3Manager-->>API_Route: S3 URL
        API_Route-->>Client: Respond with metadata (S3 URL)
    else
        API_Route-->>Client: Respond with metadata (local path)
    end
Loading

Suggested reviewers

  • hoophalab
  • junhaoliao

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c73cb1 and 66f6da9.

📒 Files selected for processing (1)
  • components/webui/server/src/app.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

🧠 Learnings (2)
📓 Common learnings
Learnt from: gibber9809
PR: y-scope/clp#504
File: components/core/src/clp_s/search/kql/CMakeLists.txt:29-29
Timestamp: 2024-10-22T15:36:04.655Z
Learning: When reviewing pull requests, focus on the changes within the PR and avoid commenting on issues outside the scope of the PR.
Learnt from: haiqi96
PR: y-scope/clp#523
File: components/core/src/clp/clp/FileCompressor.hpp:58-78
Timestamp: 2024-10-24T14:25:17.978Z
Learning: When reviewing legacy code refactors, avoid suggesting changes that would extend the scope of the PR.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/app.ts (3)
Learnt from: junhaoliao
PR: y-scope/clp#939
File: components/package-template/src/etc/clp-config.yml:64-64
Timestamp: 2025-06-22T04:01:43.409Z
Learning: The new webui architecture uses Fastify with Pino logging instead of the previous Winston-based logging system that was removed during the webui refactoring.
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: junhaoliao
PR: y-scope/clp#899
File: components/log-viewer-webui/server/src/main.ts:50-58
Timestamp: 2025-05-13T19:38:31.164Z
Learning: When using Fastify's `app.close()` method, always wrap it in a try/catch block to properly handle shutdown errors. The close() method returns a Promise that can reject if errors occur during the shutdown process (especially with plugins using onClose hooks), and unhandled rejections could cause the application to hang.
🔇 Additional comments (1)
components/webui/server/src/app.ts (1)

20-21: Function signature simplification looks good.

The removal of the options parameter aligns with the elimination of database-related setup from this legacy plugin. The simplified signature is appropriate as the plugin now only handles S3Manager and static routes registration.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@davemarco davemarco changed the title feat(webui): Migrate extract stream route and plugin to new Fastify architecture/ feat(webui): Migrate extract stream route and plugin to new Fastify architecture. Jul 3, 2025
@davemarco davemarco changed the title feat(webui): Migrate extract stream route and plugin to new Fastify architecture. refactor(webui): Migrate extract stream route and plugin to new Fastify architecture. Jul 3, 2025
@junhaoliao junhaoliao requested a review from hoophalab July 3, 2025 21:47
@davemarco
Copy link
Contributor Author

@hoophalab , i merged main into this and some smaller changes

@davemarco davemarco marked this pull request as ready for review July 11, 2025 16:02
@davemarco davemarco requested a review from a team as a code owner July 11, 2025 16:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d4c676 and 3951c6a.

📒 Files selected for processing (17)
  • components/webui/client/src/api/stream-files/index.ts (1 hunks)
  • components/webui/client/src/ui/QueryStatus.tsx (1 hunks)
  • components/webui/client/vite.config.ts (1 hunks)
  • components/webui/server/src/app.ts (1 hunks)
  • components/webui/server/src/fastify-v2/app.ts (1 hunks)
  • components/webui/server/src/fastify-v2/plugins/app/QueryJobDbManager/index.ts (1 hunks)
  • components/webui/server/src/fastify-v2/plugins/app/QueryJobDbManager/typings.ts (1 hunks)
  • components/webui/server/src/fastify-v2/plugins/app/StreamFileManager.ts (1 hunks)
  • components/webui/server/src/fastify-v2/plugins/app/search/QueryJobsDbManager/index.ts (0 hunks)
  • components/webui/server/src/fastify-v2/plugins/app/search/QueryJobsDbManager/typings.ts (0 hunks)
  • components/webui/server/src/fastify-v2/routes/api/search/index.ts (6 hunks)
  • components/webui/server/src/fastify-v2/routes/api/search/typings.ts (1 hunks)
  • components/webui/server/src/fastify-v2/routes/api/search/utils.ts (2 hunks)
  • components/webui/server/src/fastify-v2/routes/api/stream-files/index.ts (1 hunks)
  • components/webui/server/src/fastify-v2/schemas/stream-files.ts (1 hunks)
  • components/webui/server/src/plugins/DbManager.ts (0 hunks)
  • components/webui/server/src/routes/query.ts (0 hunks)
💤 Files with no reviewable changes (4)
  • components/webui/server/src/fastify-v2/plugins/app/search/QueryJobsDbManager/typings.ts
  • components/webui/server/src/fastify-v2/plugins/app/search/QueryJobsDbManager/index.ts
  • components/webui/server/src/routes/query.ts
  • components/webui/server/src/plugins/DbManager.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

🧠 Learnings (13)
📓 Common learnings
Learnt from: gibber9809
PR: y-scope/clp#504
File: components/core/src/clp_s/search/kql/CMakeLists.txt:29-29
Timestamp: 2024-10-22T15:36:04.655Z
Learning: When reviewing pull requests, focus on the changes within the PR and avoid commenting on issues outside the scope of the PR.
Learnt from: haiqi96
PR: y-scope/clp#523
File: components/core/src/clp/clp/FileCompressor.hpp:58-78
Timestamp: 2024-10-24T14:25:17.978Z
Learning: When reviewing legacy code refactors, avoid suggesting changes that would extend the scope of the PR.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/client/src/api/stream-files/index.ts (1)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/client/src/ui/QueryStatus.tsx (2)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:35-41
Timestamp: 2024-11-19T19:52:43.429Z
Learning: For internal APIs in `components/log-viewer-webui/client/src/api/query.js`, runtime validation of parameters may not be necessary since the APIs are not exposed to end users, and JsDoc type annotations may be sufficient.
components/webui/server/src/fastify-v2/app.ts (3)
Learnt from: junhaoliao
PR: y-scope/clp#939
File: components/package-template/src/etc/clp-config.yml:64-64
Timestamp: 2025-06-22T04:01:43.409Z
Learning: The new webui architecture uses Fastify with Pino logging instead of the previous Winston-based logging system that was removed during the webui refactoring.
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: junhaoliao
PR: y-scope/clp#899
File: components/log-viewer-webui/server/src/main.ts:50-58
Timestamp: 2025-05-13T19:38:31.164Z
Learning: When using Fastify's `app.close()` method, always wrap it in a try/catch block to properly handle shutdown errors. The close() method returns a Promise that can reject if errors occur during the shutdown process (especially with plugins using onClose hooks), and unhandled rejections could cause the application to hang.
components/webui/client/vite.config.ts (1)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/fastify-v2/routes/api/search/utils.ts (1)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/fastify-v2/routes/api/search/typings.ts (1)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/fastify-v2/schemas/stream-files.ts (1)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/app.ts (4)
Learnt from: junhaoliao
PR: y-scope/clp#939
File: components/package-template/src/etc/clp-config.yml:64-64
Timestamp: 2025-06-22T04:01:43.409Z
Learning: The new webui architecture uses Fastify with Pino logging instead of the previous Winston-based logging system that was removed during the webui refactoring.
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: junhaoliao
PR: y-scope/clp#899
File: components/log-viewer-webui/server/src/main.ts:50-58
Timestamp: 2025-05-13T19:38:31.164Z
Learning: When using Fastify's `app.close()` method, always wrap it in a try/catch block to properly handle shutdown errors. The close() method returns a Promise that can reject if errors occur during the shutdown process (especially with plugins using onClose hooks), and unhandled rejections could cause the application to hang.
Learnt from: junhaoliao
PR: y-scope/clp#899
File: components/log-viewer-webui/server/src/main.ts:50-58
Timestamp: 2025-05-13T19:38:31.164Z
Learning: In Fastify applications, the `app.close()` method returns a Promise that can reject if errors occur during shutdown. Always wrap it in a try/catch block to properly handle shutdown errors and set the process exit code to prevent the application from hanging.
components/webui/server/src/fastify-v2/routes/api/stream-files/index.ts (2)
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/fastify-v2/routes/api/search/index.ts (1)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/fastify-v2/plugins/app/QueryJobDbManager/index.ts (1)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/fastify-v2/plugins/app/StreamFileManager.ts (3)
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: junhaoliao
PR: y-scope/clp#939
File: components/package-template/src/etc/clp-config.yml:64-64
Timestamp: 2025-06-22T04:01:43.409Z
Learning: The new webui architecture uses Fastify with Pino logging instead of the previous Winston-based logging system that was removed during the webui refactoring.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
🧬 Code Graph Analysis (3)
components/webui/server/src/fastify-v2/routes/api/search/utils.ts (1)
components/webui/server/src/fastify-v2/routes/api/search/typings.ts (1)
  • UpdateSearchSignalWhenJobsFinishProps (50-50)
components/webui/server/src/fastify-v2/schemas/stream-files.ts (1)
components/webui/client/src/typings/query.ts (1)
  • QUERY_JOB_TYPE (94-94)
components/webui/server/src/fastify-v2/routes/api/search/index.ts (1)
components/webui/client/src/typings/query.ts (1)
  • QUERY_JOB_TYPE (94-94)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: conventional-commits
🔇 Additional comments (15)
components/webui/client/src/ui/QueryStatus.tsx (1)

13-13: Import path correctly updated to reflect API restructuring.

The import change aligns with the backend migration from /query/extract-stream to /api/stream-files/extract endpoint.

components/webui/client/src/api/stream-files/index.ts (1)

41-41: API endpoint correctly updated to match new backend route.

The endpoint change from /query/extract-stream to /api/stream-files/extract aligns with the Fastify architecture migration.

components/webui/client/vite.config.ts (1)

25-26: Proxy configuration comment updated to reflect multiple targets.

The comment change from "target" to "targets" correctly reflects the current proxy configuration structure.

components/webui/server/src/fastify-v2/app.ts (1)

42-42: FastifyV1App registration simplified by removing database configuration options.

The removal of sqlDbUser and sqlDbPass options aligns with the migration away from the legacy DbManager plugin to the new architecture.

components/webui/server/src/fastify-v2/plugins/app/QueryJobDbManager/typings.ts (1)

1-6: Well-defined polling interval constant with appropriate value.

The 500ms interval strikes a good balance between responsiveness and performance for job status polling.

components/webui/server/src/fastify-v2/routes/api/search/utils.ts (1)

60-78: LGTM! Consistent parameter renaming.

The renaming from queryJobsDbManager to queryJobDbManager is correctly applied throughout the function, including the documentation, parameter declaration, and method calls.

components/webui/server/src/fastify-v2/routes/api/search/typings.ts (1)

33-33: Type definition correctly updated.

The property rename aligns with the new QueryJobDbManager plugin name and maintains consistency with the implementation in utils.ts.

components/webui/server/src/app.ts (1)

21-23: Clean refactoring removing database dependencies.

The simplified plugin signature correctly reflects the removal of database configuration, aligning with the new modular architecture where database management is handled by dedicated plugins.

components/webui/server/src/fastify-v2/schemas/stream-files.ts (2)

11-18: Good handling of null values in union type.

The comment correctly explains why Type.Null() must come before Type.String() to prevent unwanted type coercion. This ensures proper validation of null dataset values.


27-32: Inconsistent naming convention in schema.

The stream_id property uses snake_case while other properties (begin_msg_ix, end_msg_ix) use snake_case and path uses lowercase. Consider standardizing the naming convention across all properties for consistency.

⛔ Skipped due to learnings
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: haiqi96
PR: y-scope/clp#620
File: components/core/src/clp/clo/clo.cpp:198-198
Timestamp: 2024-12-02T22:36:17.847Z
Learning: The existing references to `file_split_id` in the codebase are acceptable and do not need to be changed.
components/webui/server/src/fastify-v2/routes/api/stream-files/index.ts (3)

36-38: Good adherence to coding guidelines.

The condition correctly uses false === <expression> pattern as specified in the coding guidelines.


45-72: Robust error handling with appropriate checks.

The implementation properly handles the extraction workflow with multiple validation points and clear error messages. The double-check pattern after job completion ensures data consistency.


74-81: Well-implemented conditional path handling.

The code correctly checks for the S3 manager decorator before use and provides appropriate fallback for local file paths.

components/webui/server/src/fastify-v2/routes/api/search/index.ts (1)

88-101: LGTM! Clean migration to unified job submission interface.

The refactoring properly uses the new submitJob method with the appropriate job type enum. The aggregation job correctly includes the aggregation_config parameter.

components/webui/server/src/fastify-v2/plugins/app/QueryJobDbManager/index.ts (1)

114-124: LGTM! Proper status checking and error handling.

The code correctly checks for terminal states and provides clear error messages for different failure scenarios. Good use of the false === pattern as per coding guidelines.

hoophalab
hoophalab previously approved these changes Jul 11, 2025
Copy link
Contributor

@hoophalab hoophalab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. just some nitpicks

Validations:

  1. run clp-text and clp-json
  2. compress hive-24hr and postgresql respectively
  3. query worked
  4. query can be successfully cancelled
  5. stream files extracted correctly

Comment on lines +81 to +82

return streamMetadata;
Copy link
Contributor

@hoophalab hoophalab Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an explicit type conversion here?
The return type of getExtractedStreamFileMetadata is StreamFileMongoDocument, but the return type is typeof StreamFileMetadataSchema. It took me some time to confirm StreamFileMongoDocument is a superset of typeof StreamFileMetadataSchema. The old code doesn't have this problem because its response is not type safe at all xD

Suggested change
return streamMetadata;
return streamMetadata as Static<typeof StreamFileMetadataSchema>;

where import {Static} from "@sinclair/typebox";

  • Do not commit suggestion directly as the syntax could be incorrect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored the code to use the same base type for StreamFileMetadataSchema and StreamFileMongoDocument to make things clearer and prevent duplication.

We generally try and avoid type conversion, and I dont think neccesary here. Typebox/Fastify/Typescript will verify that the response matches the declared typebox type, like if you didnt return StreamFileMetadataSchema here, there would be a built error and linter will complain. Like there is already a type assertion in effect, so I dont believe we should cast it.

Copy link
Contributor

@hoophalab hoophalab Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the method we are going to take, then I would recommend rename StreamFileMongoDocument as StreamFileMetadata (or StreamFileMetadataSchemaType or something similar).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay done

}: SubmitExtractStreamJobProps): Promise<AxiosResponse<ExtractStreamResp>> => {
return await axios.post(
"/query/extract-stream",
"/api/stream-files/extract",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: should this be considered as a breaking change refactor(webui)!: or it is not because this is an internal api?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our policy is to mark breaking changes for changes that would be visible to users (since that requires that we bump the relevant version number). So if this is purely internal to this repo, I would say it's not breaking.

@davemarco
Copy link
Contributor Author

@hoophalab ready for rereview

Copy link
Contributor

@hoophalab hoophalab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

just a friendly reminder to remove the duplicate "Marco" and other unrelated authors from the co-author list when you merge

Copy link
Member

@junhaoliao junhaoliao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deferring to @hoophalab 's review

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: what's the plan for the static server and s3manager plugins in this file? i.e., do we plan to migrate them as well in the near future, or to keep it in this "v1" plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i already put up the s3 manager pr. The static i will do later. we are going to delete the v1 plugin

@davemarco davemarco merged commit 9dc9421 into y-scope:main Jul 14, 2025
7 checks passed
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.

4 participants