Skip to content

refactor(webui): Migrate S3Manager to new Fastify architecture.#1098

Merged
davemarco merged 14 commits into
y-scope:mainfrom
davemarco:s3move
Jul 15, 2025
Merged

refactor(webui): Migrate S3Manager to new Fastify architecture.#1098
davemarco merged 14 commits into
y-scope:mainfrom
davemarco:s3move

Conversation

@davemarco

@davemarco davemarco commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

Description

PR moves extract S3Manager into new fastify architecture. This is a chain of PRs which started with #1027

There are some minor style changes as well

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

I am still testing... on aws. Likely @hoophalab will not be able to test since no access, so will have to rely on my validation.

Summary by CodeRabbit

  • Refactor
    • Updated internal naming conventions for the S3 manager integration, including changes to property casing and plugin registration.
    • The S3 manager now reads configuration directly from a static settings file instead of passed options.
    • Introduced a new constant for pre-signed URL expiry time.

@coderabbitai

coderabbitai Bot commented Jul 11, 2025

Copy link
Copy Markdown
Contributor
## Walkthrough

The changes refactor the S3Manager Fastify plugin to read configuration directly from a static JSON file instead of receiving options, rename its decorator property to "S3Manager" (capitalized), and update all usages accordingly. A new constant for pre-signed URL expiry is introduced, and related import statements are adjusted.

## Changes

| Files / File Groups                                                                 | Change Summary                                                                                       |
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
| components/webui/server/src/app.ts                                                 | Removed S3Manager and settings imports; deleted conditional S3Manager plugin registration.        |
| components/webui/server/src/fastify-v2/plugins/app/S3Manager/index.ts              | Refactored plugin to use static settings, renamed decorator to "S3Manager", updated logging, imports.|
| components/webui/server/src/fastify-v2/plugins/app/S3Manager/typings.ts            | Added and exported PRE_SIGNED_URL_EXPIRY_TIME_SECONDS constant.                                   |
| components/webui/server/src/fastify-v2/routes/api/stream-files/index.ts            | Updated decorator/property checks and usage from "s3Manager" to "S3Manager".                      |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Client
    participant FastifyApp
    participant S3Manager

    Client->>FastifyApp: Request stream file
    alt S3Manager configured
        FastifyApp->>S3Manager: Generate pre-signed URL
        S3Manager-->>FastifyApp: Return URL
        FastifyApp-->>Client: Respond with pre-signed URL
    else S3Manager not configured
        FastifyApp-->>Client: Respond with error or fallback
    end

Possibly related PRs

Suggested reviewers

  • hoophalab
  • junhaoliao

<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

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


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 6842884f368468eda1225ac218b22134cd6daa66 and 4eedc87a321b19bde328746727eb6880f37a18f9.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `components/webui/server/src/fastify-v2/plugins/app/S3Manager/index.ts` (2 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>📓 Path-based instructions (1)</summary>

<details>
<summary>**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}</summary>


 Instructions used from: 

**Sources:**
⚙️ **CodeRabbit Configuration File**


</details>

</details><details>
<summary>🧠 Learnings (2)</summary>

<details>
<summary>📓 Common learnings</summary>

Learnt from: gibber9809
PR: #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: #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: davemarco
PR: #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: #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: haiqi96
PR: #673
File: components/log-viewer-webui/server/src/S3Manager.js:0-0
Timestamp: 2025-01-17T23:25:38.165Z
Learning: In S3Manager.js, URL validation is handled by the URL constructor which throws TypeError for invalid URLs, making additional scheme (s3://) validation redundant.


</details>
<details>
<summary>components/webui/server/src/fastify-v2/plugins/app/S3Manager/index.ts (7)</summary>

Learnt from: davemarco
PR: #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: #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: #743
File: components/log-viewer-webui/server/src/plugins/S3Manager.ts:76-76
Timestamp: 2025-04-07T09:30:20.684Z
Learning: In the S3Manager plugin, an isEnabled option should be added and checked instead of checking if the region is null. This would make the plugin's behavior more explicit.


Learnt from: junhaoliao
PR: #743
File: components/log-viewer-webui/server/src/plugins/S3Manager.ts:76-76
Timestamp: 2025-04-07T09:30:20.684Z
Learning: In the S3Manager plugin, an isEnabled option should be added and checked instead of checking if the region is null. This would make the plugin's behavior more explicit.


Learnt from: haiqi96
PR: #852
File: components/clp-package-utils/clp_package_utils/scripts/native/compress.py:151-160
Timestamp: 2025-04-25T20:46:20.140Z
Learning: For S3 URLs without region specifications (legacy global endpoints), either assign a default region (us-east-1) or throw a clear error message requiring region specification in the URL. This addresses validation issues in components like S3InputConfig that require a non-nullable region string.


Learnt from: haiqi96
PR: #673
File: components/log-viewer-webui/server/src/routes/query.js:9-10
Timestamp: 2025-01-17T22:33:23.547Z
Learning: When initializing S3Manager in log-viewer-webui, both StreamFilesS3Region and StreamFilesS3PathPrefix settings must be non-null for S3 functionality to work correctly.


Learnt from: junhaoliao
PR: #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.


</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (3)</summary><blockquote>

<details>
<summary>components/webui/server/src/fastify-v2/plugins/app/S3Manager/index.ts (3)</summary>

`6-10`: **Import changes support the architectural migration.**

The refactored imports correctly support the migration to the new Fastify architecture by:
- Using the standard `fp` alias for fastify-plugin
- Reading configuration from the static settings.json file
- Importing the extracted constant from the typings module

---

`63-63`: **Interface property correctly renamed to match decorator.**

The interface property has been appropriately renamed from `s3Manager` to `S3Manager` to maintain consistency with the capitalized decorator property used throughout the codebase.

---

`67-84`: **Plugin refactoring successfully addresses previous review concerns.**

The plugin function has been well-refactored to:
- Read configuration from settings.json instead of accepting options
- Follow yoda style comparisons as required by coding guidelines
- Include improved lint suppression comments with corrected spelling
- Maintain proper conditional decoration based on region availability

The changes align with the PR objective of migrating S3Manager to the new Fastify architecture while preserving existing functionality.

</details>

</blockquote></details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACJ/ADM0MXwKAAoAdxIBbHgASi4AWXgiKhpIAGUAZnzMNFI+AkhyNMgAMTREcTj5ZwYEGjFsf2jINPb7bAFmdRp6OUhsREpIWjQpZh78d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DgKgpzaAdCVgjzjzKKoAJyi5dzdQsKuKBADgFylAKgCLdQJyty9RMgaL3y4g8KWKzg4gTgTy5koBGzcBmyfM2yD4RQMhaB2MMkTygA=== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=y-scope/clp&utm_content=1098):

- 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](https://www.coderabbit.ai/contact-us/support) 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](https://docs.coderabbit.ai/finishing-touches/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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@davemarco davemarco requested a review from hoophalab July 11, 2025 17:17
@davemarco davemarco changed the title refactor(webui): Migrate extract S3Manager to new Fastify architecture. refactor(webui): Migrate extract S3Manager to new Fastify architecture. Jul 11, 2025
@davemarco davemarco marked this pull request as ready for review July 14, 2025 15:08
@davemarco davemarco requested a review from a team as a code owner July 14, 2025 15:08
@davemarco

Copy link
Copy Markdown
Contributor Author
Screenshot 2025-07-14 at 11 07 03 AM

I tested this with my s3 credentials and it still works..

@davemarco

Copy link
Copy Markdown
Contributor Author

@hoophalab , now that i test myself please review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5b7ea55 and 065da2d.

📒 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: 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.
components/webui/server/src/app.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#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.
⏰ 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: lint-check (macos-latest)
🔇 Additional comments (1)
components/webui/server/src/app.ts (1)

1-57: Confirm S3Manager removal in v1 and registration in v2

  • No remaining S3Manager references in components/webui/server/src/app.ts (v1 plugin).
  • v2 plugin implementation lives in
    components/webui/server/src/fastify-v2/plugins/app/S3Manager/index.ts.
  • Route handler in
    components/webui/server/src/routes/query.ts
    correctly checks fastify.hasDecorator("S3Manager") and falls back when unset.

Please verify that your v2 Fastify bootstrap (entrypoint) registers the S3Manager plugin and that querying routes produce valid pre-signed URLs in environments where S3 is configured.

Comment thread components/webui/server/src/app.ts Outdated
@davemarco davemarco changed the title refactor(webui): Migrate extract S3Manager to new Fastify architecture. refactor(webui): Migrate S3Manager to new Fastify architecture. Jul 14, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 065da2d and 11e957d.

📒 Files selected for processing (2)
  • components/webui/server/.env (1 hunks)
  • components/webui/server/src/app.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • components/webui/server/src/app.ts
🧰 Additional context used
🧠 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: 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#743
File: components/log-viewer-webui/server/src/plugins/S3Manager.ts:76-76
Timestamp: 2025-04-07T09:30:20.684Z
Learning: In the S3Manager plugin, an `isEnabled` option should be added and checked instead of checking if the region is null. This would make the plugin's behavior more explicit.
Learnt from: junhaoliao
PR: y-scope/clp#743
File: components/log-viewer-webui/server/src/plugins/S3Manager.ts:76-76
Timestamp: 2025-04-07T09:30:20.684Z
Learning: In the S3Manager plugin, an `isEnabled` option should be added and checked instead of checking if the region is null. This would make the plugin's behavior more explicit.
Learnt from: haiqi96
PR: y-scope/clp#673
File: components/log-viewer-webui/server/src/routes/query.js:9-10
Timestamp: 2025-01-17T22:33:23.547Z
Learning: When initializing S3Manager in log-viewer-webui, both StreamFilesS3Region and StreamFilesS3PathPrefix settings must be non-null for S3 functionality to work correctly.
components/webui/server/.env (1)
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 webui server logging can be configured via LOG_LEVEL and WEBUI_LOGS_DIR environment variables, with file logging enabled automatically in non-TTY environments when a logs directory is specified.
🔇 Additional comments (1)
components/webui/server/.env (1)

7-7: Hard-coded client proxies still target port 3000

We’ve confirmed two lingering references in the Vite client config that must be updated now that the server listens on 3001:

• components/webui/client/vite.config.ts

  • Line with target: "http://localhost:3000/"
  • Line with target: "ws://localhost:3000/"

Please update these to port 3001—or better yet, read the backend URL from an env var (for example VITE_SERVER_URL) to avoid future drift:

-    target: "http://localhost:3000/",
+    target: process.env.VITE_SERVER_URL || "http://localhost:3001/",-    target: "ws://localhost:3000/",
+    target: process.env.VITE_SERVER_URL?.replace(/^http/, "ws") || "ws://localhost:3001/",

[f​ix_required]

Comment thread components/webui/server/.env Outdated
@davemarco

Copy link
Copy Markdown
Contributor Author

@hoophalab i merged main into this

hoophalab
hoophalab previously approved these changes Jul 14, 2025

@hoophalab hoophalab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The code looks good to me. I'm relying on Marco's validation, which looks correct.

@junhaoliao junhaoliao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

posted some questions


// Only decorate if the region is set (i.e. s3 support is configured in package)
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (region) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we check if the region is not null or empty here?

const profile = settings.StreamFilesS3Profile;

// Only decorate if the region is set (i.e. s3 support is configured in package)
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we document why this lint suppression is needed?

declare module "fastify" {
interface FastifyInstance {
s3Manager?: S3Manager;
export interface FastifyInstance {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we want to export this now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed

junhaoliao
junhaoliao previously approved these changes Jul 14, 2025

@junhaoliao junhaoliao left a comment

Copy link
Copy Markdown
Member

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

@davemarco davemarco dismissed stale reviews from junhaoliao and hoophalab via 6842884 July 14, 2025 20:25
@davemarco davemarco requested a review from junhaoliao July 14, 2025 20:25
@davemarco

Copy link
Copy Markdown
Contributor Author

addressed @junhaoliao comments

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 11e957d and 6842884.

📒 Files selected for processing (2)
  • components/webui/server/src/fastify-v2/plugins/app/S3Manager/index.ts (2 hunks)
  • components/webui/server/src/fastify-v2/routes/api/stream-files/index.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 (3)
📓 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#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: haiqi96
PR: y-scope/clp#673
File: components/log-viewer-webui/server/src/S3Manager.js:0-0
Timestamp: 2025-01-17T23:25:38.165Z
Learning: In S3Manager.js, URL validation is handled by the URL constructor which throws TypeError for invalid URLs, making additional scheme (s3://) validation redundant.
components/webui/server/src/fastify-v2/routes/api/stream-files/index.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: haiqi96
PR: y-scope/clp#673
File: components/log-viewer-webui/server/src/S3Manager.js:0-0
Timestamp: 2025-01-17T23:25:38.165Z
Learning: In S3Manager.js, URL validation is handled by the URL constructor which throws TypeError for invalid URLs, making additional scheme (s3://) validation redundant.
Learnt from: haiqi96
PR: y-scope/clp#673
File: components/log-viewer-webui/server/src/routes/query.js:9-10
Timestamp: 2025-01-17T22:33:23.547Z
Learning: When initializing S3Manager in log-viewer-webui, both StreamFilesS3Region and StreamFilesS3PathPrefix settings must be non-null for S3 functionality to work correctly.
components/webui/server/src/fastify-v2/plugins/app/S3Manager/index.ts (6)
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#743
File: components/log-viewer-webui/server/src/plugins/S3Manager.ts:76-76
Timestamp: 2025-04-07T09:30:20.684Z
Learning: In the S3Manager plugin, an `isEnabled` option should be added and checked instead of checking if the region is null. This would make the plugin's behavior more explicit.
Learnt from: junhaoliao
PR: y-scope/clp#743
File: components/log-viewer-webui/server/src/plugins/S3Manager.ts:76-76
Timestamp: 2025-04-07T09:30:20.684Z
Learning: In the S3Manager plugin, an `isEnabled` option should be added and checked instead of checking if the region is null. This would make the plugin's behavior more explicit.
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: haiqi96
PR: y-scope/clp#673
File: components/log-viewer-webui/server/src/routes/query.js:9-10
Timestamp: 2025-01-17T22:33:23.547Z
Learning: When initializing S3Manager in log-viewer-webui, both StreamFilesS3Region and StreamFilesS3PathPrefix settings must be non-null for S3 functionality to work correctly.
🪛 GitHub Actions: clp-lint
components/webui/server/src/fastify-v2/plugins/app/S3Manager/index.ts

[error] 76-76: ESLint: Expected literal to be on the left side of !== (yoda). Two occurrences at column 13 and 32.

🔇 Additional comments (4)
components/webui/server/src/fastify-v2/routes/api/stream-files/index.ts (1)

72-73: LGTM! Decorator name updated for consistency.

The changes correctly update the decorator name from s3Manager to S3Manager to match the refactored plugin implementation. The conditional logic and usage remain appropriate.

components/webui/server/src/fastify-v2/plugins/app/S3Manager/index.ts (3)

6-6: LGTM! Import renamed for consistency.

The import rename from fastifyPlugin to fp follows common naming conventions for this plugin utility.


8-10: LGTM! Configuration and typings imports added.

The addition of settings import and PRE_SIGNED_URL_EXPIRY_TIME_SECONDS constant import supports the refactoring to centralize configuration within the plugin.


63-63: LGTM! Interface updated to match decorator name change.

The FastifyInstance interface correctly reflects the renamed decorator from s3Manager to S3Manager.

@davemarco davemarco merged commit 27a2235 into y-scope:main Jul 15, 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.

3 participants