Skip to content

[Server] Throw the SDK's own RuntimeException from FileSessionStore - #404

Open
chr-hertel wants to merge 1 commit into
modelcontextprotocol:mainfrom
chr-hertel:fix/file-session-store-package-exception
Open

[Server] Throw the SDK's own RuntimeException from FileSessionStore#404
chr-hertel wants to merge 1 commit into
modelcontextprotocol:mainfrom
chr-hertel:fix/file-session-store-package-exception

Conversation

@chr-hertel

@chr-hertel chr-hertel commented Jul 27, 2026

Copy link
Copy Markdown
Member

FileSessionStore::__construct() threw the global \RuntimeException for an unwritable session directory — the last throw in src/ outside Mcp\Exception\ExceptionInterface, so catch (ExceptionInterface) missed it.

Mcp\Exception\RuntimeException extends \RuntimeException, so the change is additive: existing catch (\RuntimeException) blocks keep working. (ConfigurationException would read better but extends InvalidArgumentException, which would break them.)

The constructor had no coverage, so FileSessionStoreTest is new — the throw, plus the directory-creation and write/read paths beside it.

Spotted while reviewing #403, but unrelated to it and older, hence split out.

The constructor guarded its unwritable-directory case with the global
`\RuntimeException`, the only throw in `src/` still outside
`Mcp\Exception\ExceptionInterface`. A consumer wrapping server setup in a
`catch (ExceptionInterface)` missed it and got an unhandled SPL exception on
a misconfigured session directory instead.

`Mcp\Exception\RuntimeException` extends `\RuntimeException`, so this is
additive: existing `catch (\RuntimeException)` blocks keep working.

The constructor had no test coverage at all, so this adds one for the throw
plus the directory-creation and write/read paths around it.
@chr-hertel chr-hertel added the enhancement Request for a new feature that's not currently supported label Jul 27, 2026
@chr-hertel chr-hertel added this to the 0.8.0 milestone Jul 27, 2026
@chr-hertel chr-hertel added the Server Issues & PRs related to the Server component label Jul 27, 2026
@chr-hertel
chr-hertel marked this pull request as ready for review July 27, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature that's not currently supported Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant