Skip to content

fix: update sessionIdGenerator#320

Merged
akitaSummer merged 2 commits intoeggjs:masterfrom
akitaSummer:fix/update-sessionIdGenerator
May 13, 2025
Merged

fix: update sessionIdGenerator#320
akitaSummer merged 2 commits intoeggjs:masterfrom
akitaSummer:fix/update-sessionIdGenerator

Conversation

@akitaSummer
Copy link
Contributor

@akitaSummer akitaSummer commented May 13, 2025

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

Summary by CodeRabbit

  • Refactor
    • Improved flexibility of session ID generation by allowing the generator to accept the current request context.
    • Enhanced session handling to support context-aware session ID generation.
  • New Features
    • Added support for custom session IDs via request headers, enabling consistent session identification across requests.

@coderabbitai
Copy link

coderabbitai bot commented May 13, 2025

## Walkthrough

The changes update the type signature of the `sessionIdGenerator` property in the MCP configuration to require a `Context` parameter, modify its usage to pass the current context when generating session IDs, add a new configuration implementation that uses request headers or UUID fallback, and update tests to verify custom session ID propagation.

## Changes

| File(s)                                                                                  | Change Summary                                                                                                 |
|-----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
| plugin/controller/lib/impl/mcp/MCPConfig.ts                                             | Changed `sessionIdGenerator` type in `MCPConfigOptions` and `MCPConfig` from `() => string` to `(ctx: Context) => string`. |
| plugin/controller/lib/impl/mcp/MCPControllerRegister.ts                                 | Updated call to `sessionIdGenerator` to pass current context `ctx` as argument.                                |
| plugin/controller/test/fixtures/apps/mcp-app/config/config.default.js                   | Added `mcp` config with `sessionIdGenerator(ctx)` that uses request header `'custom-session-id'` or falls back to UUID. |
| plugin/controller/test/mcp/mcp.test.ts                                                  | Modified test to send custom header `'custom-session-id'` and assert `sessionId` matches this custom session ID. |
| plugin/controller/test/mcp/mcpCluster.test.ts                                           | Modified test to send custom header `'custom-session-id'` and assert `sessionId` matches this custom session ID. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Client
    participant MCPControllerRegister
    participant MCPConfig
    participant SessionIdGenerator

    Client->>MCPControllerRegister: HTTP request received
    MCPControllerRegister->>MCPConfig: Access sessionIdGenerator
    MCPControllerRegister->>SessionIdGenerator: sessionIdGenerator(ctx)
    SessionIdGenerator-->>MCPControllerRegister: Returns session ID
    MCPControllerRegister-->>Client: Continue processing with session ID

Suggested reviewers

  • killagu

Poem

In the warren of code, a change hops by,
Now session IDs know the who and the why.
Context-aware, with a twitch of the ear,
Rabbits rejoice—new signatures appear!
🐇✨ With every request, a smarter ID,
Thanks to the team, from burrow to tree!


<!-- walkthrough_end -->
<!-- This is an auto-generated comment: all tool run failures by coderabbit.ai -->

> [!WARNING]
> There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
> 
> <details>
> <summary>🔧 ESLint</summary>
> 
> > If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
> 
> <details>
> <summary>plugin/controller/lib/impl/mcp/MCPConfig.ts</summary>
> 
> 
> Oops! Something went wrong! :(
> 
> ESLint: 8.57.1
> 
> ESLint couldn't find the plugin "eslint-plugin-eggache".
> 
> (The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".)
> 
> It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
> 
>     npm install eslint-plugin-eggache@latest --save-dev
> 
> The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js".
> 
> If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
> 
> 
> </details>
> 
> <details>
> <summary>plugin/controller/test/fixtures/apps/mcp-app/config/config.default.js</summary>
> 
> 
> Oops! Something went wrong! :(
> 
> ESLint: 8.57.1
> 
> ESLint couldn't find the plugin "eslint-plugin-eggache".
> 
> (The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".)
> 
> It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
> 
>     npm install eslint-plugin-eggache@latest --save-dev
> 
> The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js".
> 
> If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
> 
> 
> </details>
> 
> <details>
> <summary>plugin/controller/test/mcp/mcp.test.ts</summary>
> 
> 
> Oops! Something went wrong! :(
> 
> ESLint: 8.57.1
> 
> ESLint couldn't find the plugin "eslint-plugin-eggache".
> 
> (The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".)
> 
> It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
> 
>     npm install eslint-plugin-eggache@latest --save-dev
> 
> The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js".
> 
> If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
> 
> 
> </details>
> 
> + 1 others
> 
> </details>

<!-- end of auto-generated comment: all tool run failures by coderabbit.ai -->


---

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

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

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

Reviewing files that changed from the base of the PR and between 410d745323e27fad33b4a31cab51a1d701d1cdb8 and deba55aa8a2633e4a62e8bc27fcaee19b6d81696.

</details>

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

* `plugin/controller/lib/impl/mcp/MCPConfig.ts` (3 hunks)
* `plugin/controller/test/fixtures/apps/mcp-app/config/config.default.js` (2 hunks)
* `plugin/controller/test/mcp/mcp.test.ts` (1 hunks)
* `plugin/controller/test/mcp/mcpCluster.test.ts` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (4)</summary>

* plugin/controller/test/mcp/mcpCluster.test.ts
* plugin/controller/test/mcp/mcp.test.ts
* plugin/controller/test/fixtures/apps/mcp-app/config/config.default.js
* plugin/controller/lib/impl/mcp/MCPConfig.ts

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (9)</summary>

* GitHub Check: Analyze (javascript)
* GitHub Check: Analyze (typescript)
* GitHub Check: Runner-ubuntu (22)
* GitHub Check: Runner-ubuntu (16)
* GitHub Check: Runner-macos (20)
* GitHub Check: Runner-ubuntu (20)
* GitHub Check: Runner-macos (18)
* GitHub Check: Runner-ubuntu (18)
* GitHub Check: Runner-macos (16)

</details>

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


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAM3gADy5sblpqD0RpRHh8DABJWgBxMmUCCmjIAHc0ZAcBZnUaejkw2A9sTL40AGt1NABlRzYu5FtIDEcBSkgAZgAmAAYULFw2yBIiIiFEAHoaTb8SbnxsstkNGDWlRAYKeG5xXPtRR6x8WNaPbm9ffyCQ5YMLzYa7oBQYXB3AR4fB8BhtBjdLxIUIkZjcWA1eAAL3gGCIn3GJCisVhYRCiAANJAphh4cxnN0qZBaPgGI52NQclh4ZhSMzMPQ0LQ2v46R4CApWOpIGxEIg0KRIERsPAlMjyIgLgAJfCVEhSCjU1Yea63e6vFn4aTjfChXj4CRqjLcUTweIMFkkXDaLzIFT4PCE3n4m0MpRhfCEzLy7kFYrkKhlfhdDDyfxedL0eDoyJsCFcp4YO3SC7ufwoZDF5akigMy0BoNoWKxF5RJgVuqIWSIGjMZBk/ytsUMG2SjNZysOUuXL4/Q7/Xvobiu5zISVTSCk9mZehPFJpcT46NZONFEpJ2HU6GhauxbAUE18GjwjDwBhoXxKH3wP0p9YJNwmYYIWGD+hWeJAiCUR4oSDpOko9BmncDzchoRj6MY4BQGQe4fGgMLEBek5MKw7BcLw/DCC8kg2i0TBKFQqjqFoOiYSYUBwKgqCYDgBBEYmJEsPmnB+GglT2EMzjyPRijKMxmjaLoYCGFhpgGEB2BEHiOxMBCFD4D4lA7MiAg7DmQE7MwDDcDsACyADCVgObk8REBouCIBwBjRL5B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GSc4QsGSVqbQAIOYUiU0UoG4jYTyWgJMXMMSYqVYWgI4YSRCQwMqR+MSKEYsbQOYZcWEQ0Y0VAKRGoRoe6toQaLoXQONLhMYUAA== -->

<!-- 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=eggjs/tegg&utm_content=320):

- 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 -->

Copy link

@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: 0

🧹 Nitpick comments (1)
plugin/controller/lib/impl/mcp/MCPControllerRegister.ts (1)

223-245: Improved request body parsing with proper error handling.

The code now consistently parses the request body upfront with robust error handling, which is a good practice. However, there's a minor grammar issue in the error message.

-            message: `Bad Request: body should is json, ${e.toString()}`,
+            message: `Bad Request: body should be json, ${e.toString()}`,
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c8080b1 and 98c450a.

📒 Files selected for processing (2)
  • plugin/controller/lib/impl/mcp/MCPConfig.ts (3 hunks)
  • plugin/controller/lib/impl/mcp/MCPControllerRegister.ts (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
plugin/controller/lib/impl/mcp/MCPControllerRegister.ts (1)
plugin/controller/lib/impl/mcp/MCPConfig.ts (1)
  • eventStore (55-57)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Analyze (typescript)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Runner-ubuntu (22)
  • GitHub Check: Runner-ubuntu (16)
  • GitHub Check: Runner-macos (18)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-ubuntu (20)
🔇 Additional comments (7)
plugin/controller/lib/impl/mcp/MCPConfig.ts (3)

1-1: Appropriate import addition for updated type definition.

The addition of the Context import from 'egg' properly supports the type expansion of the sessionIdGenerator function.


11-11: Good type expansion for more flexible session ID generation.

The expanded type definition allows the sessionIdGenerator to optionally accept a request context parameter, providing more flexibility while maintaining backward compatibility with existing implementations.


21-21: Consistent type updating in class property.

The private property's type definition is properly updated to match the interface, ensuring type consistency throughout the code.

plugin/controller/lib/impl/mcp/MCPControllerRegister.ts (4)

246-274: Well-structured initialization request handling.

The initialization request handling is now more clearly structured. The refactored code extracts the event store, creates a transport with the correct session ID generator, and properly handles the request with the parsed body.


290-290: Consistent request body handling.

The transport handler now correctly uses the pre-parsed body, ensuring consistent request processing across different conditions.


304-315: Improved error handling for missing session ID.

Adding explicit error handling for requests without a valid session ID improves the robustness of the code and provides clearer feedback to clients.


251-251:

Details

✅ Verification successful

Context-aware session ID generation.

The updated code now properly passes the context to the session ID generator, aligning with the expanded type definition in MCPConfig.ts.


🏁 Script executed:

#!/bin/bash
# Check if there are any custom implementations of sessionIdGenerator that might break with the new signature

# Search for custom implementations of sessionIdGenerator
rg -A 5 -B 5 "sessionIdGenerator\s*:" --type ts

Length of output: 5214


Approved: Context-aware session ID Generation

The MCPControllerRegister now correctly passes ctx to sessionIdGenerator, matching the expanded ((ctx?: Context) => string) signature in MCPConfig.ts. We verified there are no custom implementations of sessionIdGenerator that would break with this change.

  • plugin/controller/lib/impl/mcp/MCPControllerRegister.ts:251

@akitaSummer akitaSummer force-pushed the fix/update-sessionIdGenerator branch 3 times, most recently from dc6aec7 to 2d77a39 Compare May 13, 2025 08:58
@akitaSummer akitaSummer force-pushed the fix/update-sessionIdGenerator branch 3 times, most recently from 4ba612d to 410d745 Compare May 13, 2025 12:51
@akitaSummer akitaSummer force-pushed the fix/update-sessionIdGenerator branch from 410d745 to deba55a Compare May 13, 2025 12:56
Copy link
Contributor

@killagu killagu left a comment

Choose a reason for hiding this comment

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

LGTM

@akitaSummer akitaSummer merged commit ffc1e19 into eggjs:master May 13, 2025
13 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.

2 participants