Skip to content

Docs/multer middleware priority - #3415

Merged
Romakita merged 1 commit into
productionfrom
docs/multer-middleware-priority
Jul 22, 2026
Merged

Docs/multer middleware priority#3415
Romakita merged 1 commit into
productionfrom
docs/multer-middleware-priority

Conversation

@Romakita

@Romakita Romakita commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Documentation
    • Added guidance on middleware execution order and authentication during file uploads.
    • Explained how to configure authentication middleware to run before file handling.
    • Included TypeScript examples for correct and incorrect priority configurations.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6355af66-6d9c-4b73-ba2d-05b5b9485d65

📥 Commits

Reviewing files that changed from the base of the PR and between 6582cb1 and 92663d6.

📒 Files selected for processing (1)
  • docs/docs/upload-files.md

Walkthrough

The upload documentation adds guidance on PlatformMulterMiddleware priority, authentication ordering, and configuring authentication middleware to run before file handling.

Changes

Upload middleware authentication documentation

Layer / File(s) Summary
Middleware ordering guidance
docs/docs/upload-files.md
Documents the -10 Multer priority, explains default-priority authentication ordering, and provides examples for correcting it with a lower priority.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the docs change about Multer middleware priority and ordering.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/multer-middleware-priority

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

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

@Romakita
Romakita force-pushed the docs/multer-middleware-priority branch from 6582cb1 to 92663d6 Compare July 22, 2026 06:13

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/platform/platform-mcp/src/services/PlatformMcpModule.ts (1)

48-52: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Avoid sharing one McpServer across concurrent request transports.
This creates a new transport per request but connects it to the injected singleton server. If the SDK keeps one active transport on the server, overlapping requests can swap or detach each other’s transport; use a fresh server per request or serialize the connects. Add a concurrent-request integration test before merging.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/platform/platform-mcp/src/services/PlatformMcpModule.ts` around
lines 48 - 52, Update the request handling around
NodeStreamableHTTPServerTransport so each concurrent request connects to its own
fresh McpServer instance instead of the injected singleton, preventing
transports from replacing or detaching one another. Preserve the existing server
configuration and request behavior, and add a concurrent-request integration
test verifying both requests complete independently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/platform/platform-mcp/src/fn/definePrompt.ts`:
- Around line 19-21: Add TSDoc immediately above the exported PromptHandler type
documenting both the no-argument and argument-taking callback signatures,
including their ServerContext parameter and GetPromptResult return type.
Explicitly note that ServerContext replaces the v1 extra/request context so the
migration-sensitive contract is clear.

In `@packages/platform/platform-mcp/src/fn/defineTool.spec.ts`:
- Around line 92-99: Update the inputSchema JSON Schema assertion in
defineTool.spec.ts to invoke validation with a valid aliasProp plus an extra
property, then assert the established additionalProperties rejection or
stripping behavior. Preserve the existing aliasing and required-field
expectations so the test continues covering the complete input-validation
contract.

In `@packages/platform/platform-mcp/src/fn/defineTool.ts`:
- Around line 164-166: Add test coverage around the async handler wrapper in
defineTool, using a user handler that inspects its second ctx argument. Assert
that the invocation’s ServerContext is forwarded unchanged, while preserving the
existing input deserialization and result behavior.

In `@packages/platform/platform-mcp/test/mcp.integration.shared.ts`:
- Around line 410-435: Extend the invalid-input test around functional-tool to
track handler invocation with a spy or counter before sendMcpRequest is called.
After the request, assert that the handler was never invoked while preserving
the existing error-payload assertions.

---

Outside diff comments:
In `@packages/platform/platform-mcp/src/services/PlatformMcpModule.ts`:
- Around line 48-52: Update the request handling around
NodeStreamableHTTPServerTransport so each concurrent request connects to its own
fresh McpServer instance instead of the injected singleton, preventing
transports from replacing or detaching one another. Preserve the existing server
configuration and request behavior, and add a concurrent-request integration
test verifying both requests complete independently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 33ffb99f-cfb2-41bd-aa9d-f88368bf2a98

📥 Commits

Reviewing files that changed from the base of the PR and between 0c8dfbd and 6582cb1.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (28)
  • docs/docs/upload-files.md
  • openspec/changes/migrate-platform-mcp-to-sdk-v2/.openspec.yaml
  • openspec/changes/migrate-platform-mcp-to-sdk-v2/design.md
  • openspec/changes/migrate-platform-mcp-to-sdk-v2/proposal.md
  • openspec/changes/migrate-platform-mcp-to-sdk-v2/specs/mcp-endpoint/spec.md
  • openspec/changes/migrate-platform-mcp-to-sdk-v2/tasks.md
  • packages/platform/platform-mcp/package.json
  • packages/platform/platform-mcp/readme.md
  • packages/platform/platform-mcp/src/decorators/resource.ts
  • packages/platform/platform-mcp/src/fn/definePrompt.ts
  • packages/platform/platform-mcp/src/fn/defineResource.ts
  • packages/platform/platform-mcp/src/fn/defineTool.spec.ts
  • packages/platform/platform-mcp/src/fn/defineTool.ts
  • packages/platform/platform-mcp/src/index.ts
  • packages/platform/platform-mcp/src/interfaces/PlatformMcpSettings.ts
  • packages/platform/platform-mcp/src/services/McpServerFactory.ts
  • packages/platform/platform-mcp/src/services/PlatformMcpModule.spec.ts
  • packages/platform/platform-mcp/src/services/PlatformMcpModule.ts
  • packages/platform/platform-mcp/src/utils/asResourceResponse.ts
  • packages/platform/platform-mcp/src/utils/asToolResponse.ts
  • packages/platform/platform-mcp/src/utils/fromJsonSchema.spec.ts
  • packages/platform/platform-mcp/src/utils/fromJsonSchema.ts
  • packages/platform/platform-mcp/src/utils/toZod.spec.ts
  • packages/platform/platform-mcp/src/utils/toZod.ts
  • packages/platform/platform-mcp/test/app/resources/TestResource.ts
  • packages/platform/platform-mcp/test/app/tools/TestTool.ts
  • packages/platform/platform-mcp/test/mcp.integration.shared.ts
  • packages/platform/platform-mcp/vitest.config.mts
💤 Files with no reviewable changes (3)
  • packages/platform/platform-mcp/src/utils/toZod.spec.ts
  • packages/platform/platform-mcp/src/utils/toZod.ts
  • packages/platform/platform-mcp/vitest.config.mts

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/platform/platform-mcp/src/services/PlatformMcpModule.ts (1)

48-52: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Avoid sharing one McpServer across concurrent request transports.
This creates a new transport per request but connects it to the injected singleton server. If the SDK keeps one active transport on the server, overlapping requests can swap or detach each other’s transport; use a fresh server per request or serialize the connects. Add a concurrent-request integration test before merging.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/platform/platform-mcp/src/services/PlatformMcpModule.ts` around
lines 48 - 52, Update the request handling around
NodeStreamableHTTPServerTransport so each concurrent request connects to its own
fresh McpServer instance instead of the injected singleton, preventing
transports from replacing or detaching one another. Preserve the existing server
configuration and request behavior, and add a concurrent-request integration
test verifying both requests complete independently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/platform/platform-mcp/src/fn/definePrompt.ts`:
- Around line 19-21: Add TSDoc immediately above the exported PromptHandler type
documenting both the no-argument and argument-taking callback signatures,
including their ServerContext parameter and GetPromptResult return type.
Explicitly note that ServerContext replaces the v1 extra/request context so the
migration-sensitive contract is clear.

In `@packages/platform/platform-mcp/src/fn/defineTool.spec.ts`:
- Around line 92-99: Update the inputSchema JSON Schema assertion in
defineTool.spec.ts to invoke validation with a valid aliasProp plus an extra
property, then assert the established additionalProperties rejection or
stripping behavior. Preserve the existing aliasing and required-field
expectations so the test continues covering the complete input-validation
contract.

In `@packages/platform/platform-mcp/src/fn/defineTool.ts`:
- Around line 164-166: Add test coverage around the async handler wrapper in
defineTool, using a user handler that inspects its second ctx argument. Assert
that the invocation’s ServerContext is forwarded unchanged, while preserving the
existing input deserialization and result behavior.

In `@packages/platform/platform-mcp/test/mcp.integration.shared.ts`:
- Around line 410-435: Extend the invalid-input test around functional-tool to
track handler invocation with a spy or counter before sendMcpRequest is called.
After the request, assert that the handler was never invoked while preserving
the existing error-payload assertions.

---

Outside diff comments:
In `@packages/platform/platform-mcp/src/services/PlatformMcpModule.ts`:
- Around line 48-52: Update the request handling around
NodeStreamableHTTPServerTransport so each concurrent request connects to its own
fresh McpServer instance instead of the injected singleton, preventing
transports from replacing or detaching one another. Preserve the existing server
configuration and request behavior, and add a concurrent-request integration
test verifying both requests complete independently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 33ffb99f-cfb2-41bd-aa9d-f88368bf2a98

📥 Commits

Reviewing files that changed from the base of the PR and between 0c8dfbd and 6582cb1.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (28)
  • docs/docs/upload-files.md
  • openspec/changes/migrate-platform-mcp-to-sdk-v2/.openspec.yaml
  • openspec/changes/migrate-platform-mcp-to-sdk-v2/design.md
  • openspec/changes/migrate-platform-mcp-to-sdk-v2/proposal.md
  • openspec/changes/migrate-platform-mcp-to-sdk-v2/specs/mcp-endpoint/spec.md
  • openspec/changes/migrate-platform-mcp-to-sdk-v2/tasks.md
  • packages/platform/platform-mcp/package.json
  • packages/platform/platform-mcp/readme.md
  • packages/platform/platform-mcp/src/decorators/resource.ts
  • packages/platform/platform-mcp/src/fn/definePrompt.ts
  • packages/platform/platform-mcp/src/fn/defineResource.ts
  • packages/platform/platform-mcp/src/fn/defineTool.spec.ts
  • packages/platform/platform-mcp/src/fn/defineTool.ts
  • packages/platform/platform-mcp/src/index.ts
  • packages/platform/platform-mcp/src/interfaces/PlatformMcpSettings.ts
  • packages/platform/platform-mcp/src/services/McpServerFactory.ts
  • packages/platform/platform-mcp/src/services/PlatformMcpModule.spec.ts
  • packages/platform/platform-mcp/src/services/PlatformMcpModule.ts
  • packages/platform/platform-mcp/src/utils/asResourceResponse.ts
  • packages/platform/platform-mcp/src/utils/asToolResponse.ts
  • packages/platform/platform-mcp/src/utils/fromJsonSchema.spec.ts
  • packages/platform/platform-mcp/src/utils/fromJsonSchema.ts
  • packages/platform/platform-mcp/src/utils/toZod.spec.ts
  • packages/platform/platform-mcp/src/utils/toZod.ts
  • packages/platform/platform-mcp/test/app/resources/TestResource.ts
  • packages/platform/platform-mcp/test/app/tools/TestTool.ts
  • packages/platform/platform-mcp/test/mcp.integration.shared.ts
  • packages/platform/platform-mcp/vitest.config.mts
💤 Files with no reviewable changes (3)
  • packages/platform/platform-mcp/src/utils/toZod.spec.ts
  • packages/platform/platform-mcp/src/utils/toZod.ts
  • packages/platform/platform-mcp/vitest.config.mts
🛑 Comments failed to post (4)
packages/platform/platform-mcp/src/fn/definePrompt.ts (1)

19-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the exported handler contract.

PromptHandler is public and now changes from the v1 extra/request context to ServerContext; add TSDoc covering both callback forms and the migration-sensitive context parameter.

As per coding guidelines, use TSDoc for public API documentation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/platform/platform-mcp/src/fn/definePrompt.ts` around lines 19 - 21,
Add TSDoc immediately above the exported PromptHandler type documenting both the
no-argument and argument-taking callback signatures, including their
ServerContext parameter and GetPromptResult return type. Explicitly note that
ServerContext replaces the v1 extra/request context so the migration-sensitive
contract is clear.

Source: Coding guidelines

packages/platform/platform-mcp/src/fn/defineTool.spec.ts (1)

92-99: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Keep the input-validation contract covered.

This assertion now checks aliasing and required fields but omits the previous additionalProperties expectation. Add an invocation containing an extra property and assert the intended rejection or stripping behavior so the JSON Schema migration cannot silently widen accepted tool inputs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/platform/platform-mcp/src/fn/defineTool.spec.ts` around lines 92 -
99, Update the inputSchema JSON Schema assertion in defineTool.spec.ts to invoke
validation with a valid aliasProp plus an extra property, then assert the
established additionalProperties rejection or stripping behavior. Preserve the
existing aliasing and required-field expectations so the test continues covering
the complete input-validation contract.
packages/platform/platform-mcp/src/fn/defineTool.ts (1)

164-166: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add coverage for the new ServerContext callback contract.

These lines now forward ctx to user handlers, but the supplied tests ignore the second parameter. Add a test handler that asserts it receives the invocation context, preventing future wrappers from silently dropping it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/platform/platform-mcp/src/fn/defineTool.ts` around lines 164 - 166,
Add test coverage around the async handler wrapper in defineTool, using a user
handler that inspects its second ctx argument. Assert that the invocation’s
ServerContext is forwarded unchanged, while preserving the existing input
deserialization and result behavior.
packages/platform/platform-mcp/test/mcp.integration.shared.ts (1)

410-435: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert that invalid input never reaches the handler.

This assertion verifies only the returned error payload; a handler could still execute and produce the same response. Add a spy or invocation counter for functional-tool and assert it remains untouched after the invalid call.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/platform/platform-mcp/test/mcp.integration.shared.ts` around lines
410 - 435, Extend the invalid-input test around functional-tool to track handler
invocation with a spy or counter before sendMcpRequest is called. After the
request, assert that the handler was never invoked while preserving the existing
error-payload assertions.

@Romakita
Romakita merged commit 65afb51 into production Jul 22, 2026
11 checks passed
@Romakita
Romakita deleted the docs/multer-middleware-priority branch July 22, 2026 06:53
@Romakita

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 8.37.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant