Skip to content

fix: centralize file path validation for tools#2150

Closed
msnandhis wants to merge 1 commit into
ChromeDevTools:mainfrom
msnandhis:fix/centralize-file-path-validation
Closed

fix: centralize file path validation for tools#2150
msnandhis wants to merge 1 commit into
ChromeDevTools:mainfrom
msnandhis:fix/centralize-file-path-validation

Conversation

@msnandhis

Copy link
Copy Markdown

Fixes #2138.

Summary

This centralizes workspace-root validation for request file path fields instead of having individual tool handlers call context.validatePath(...) directly.

Changes included:

  • add required annotations.filePathFields metadata to tool definitions
  • validate annotated request fields centrally in ToolHandler before handler execution
  • annotate existing tools that accept request path fields such as filePath, requestFilePath, responseFilePath, outputDirPath, and extension path
  • remove duplicated per-tool validation calls for direct request path fields
  • keep non-request validation in reload_extension, because that path is resolved from existing extension state rather than from request params
  • add ToolHandler coverage to ensure annotated file path fields are validated before the handler runs

Testing

  • npm run format
  • npm run check-format
  • npm run test tests/ToolHandler.test.ts

I also started a full npm run test; it built and ran many tests locally, then remained quiet in a daemon/browser section, so I stopped the local run and cleaned up the spawned daemon processes rather than leaving them running.

@google-cla

google-cla Bot commented May 28, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment thread src/tools/slim/tools.ts
category: ToolCategory.DEBUGGING,
// Not read-only due to filePath param.
readOnlyHint: false,
filePathFields: [],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR, we discussed it offline and we actually want to move filePathFields to the same level as blockedByDialog (i.e., outside of annotations). cc @Lightning00Blade

@ranieleda-ui

ranieleda-ui commented Jun 2, 2026 via email

Copy link
Copy Markdown

samiyac pushed a commit to bcfmtolgahan/chrome-devtools-mcp that referenced this pull request Jun 5, 2026
pull Bot pushed a commit to CrazyForks/chrome-devtools-mcp that referenced this pull request Jun 8, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.2.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v1.1.1...chrome-devtools-mcp-v1.2.0)
(2026-06-08)


### 🎉 Features

* add experimental TOON support for structured content output
([ChromeDevTools#2042](ChromeDevTools#2042))
([aa33bff](ChromeDevTools@aa33bff))
* Adds close_heapsnapshot MCP tool
([ChromeDevTools#2174](ChromeDevTools#2174))
([8713b93](ChromeDevTools@8713b93))
* Handle multiple providers of third-party developer tools
([ChromeDevTools#2168](ChromeDevTools#2168))
([30d59a7](ChromeDevTools@30d59a7))
* implement extension service worker logs
([ChromeDevTools#1915](ChromeDevTools#1915))
([29e3898](ChromeDevTools@29e3898))
* memory debugging tools
([ChromeDevTools#2169](ChromeDevTools#2169))
([0217397](ChromeDevTools@0217397))
* support allowedUrlPattern & blockedUrlPattern Options
([ChromeDevTools#2037](ChromeDevTools#2037))
([02b4492](ChromeDevTools@02b4492))


### 🛠️ Fixes

* Cursor plugin homepage setting field
([ChromeDevTools#2173](ChromeDevTools#2173))
([8971890](ChromeDevTools@8971890))


### 📄 Documentation

* **skill:** guide agent to prompt for --categoryExtensions
([ChromeDevTools#2189](ChromeDevTools#2189))
([8b458f7](ChromeDevTools@8b458f7))


### ⚡ Performance

* lighthouse file saves to run concurrently
([ChromeDevTools#2178](ChromeDevTools#2178))
([f90f863](ChromeDevTools@f90f863))


### 🏗️ Refactor

* change type of logger
([ChromeDevTools#2165](ChromeDevTools#2165))
([bf0574d](ChromeDevTools@bf0574d))
* use validate files on the tool level
([ChromeDevTools#2152](ChromeDevTools#2152))
([2e039c0](ChromeDevTools@2e039c0)),
closes
[ChromeDevTools#2150](ChromeDevTools#2150)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

[Task]: Refactor path validation

3 participants