Mattermost: guard probe fetches#58529
Conversation
Greptile SummaryThis PR routes Mattermost account probes through the shared
Confidence Score: 5/5Safe to merge — the SSRF guard is correctly integrated with proper resource cleanup on all code paths. All three changed files are correct: No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/mattermost/src/mattermost/probe.test.ts
Line: 114-126
Comment:
**Missing `release` assertion on throw path**
The "returns fetch error when request throws" test uses `mockFetchGuard.mockRejectedValueOnce(...)`, so no `{ response, release }` is returned and no caller-side `release` call is expected — this is correct by design. However, it might be worth adding a negative assertion (`expect(mockRelease).not.toHaveBeenCalled()`) to explicitly document and guard that invariant, similar to how the success-path tests assert `toHaveBeenCalledTimes(1)`. Without it, a future regression that accidentally returns a release handle before throwing could go undetected.
```suggestion
await expect(probeMattermost("https://mm.example.com", "token")).resolves.toEqual(
expect.objectContaining({
ok: false,
status: null,
error: "network down",
}),
);
expect(mockRelease).not.toHaveBeenCalled();
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "Mattermost: guard probe fetches" | Re-trigger Greptile |
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@codex review |
|
@greptile review |
Summary
allowPrivateNetworkaccount setting into probe requestsChanges
extensions/mattermost/src/mattermost/probe.tsto callfetchWithSsrFGuardwith a dedicated audit context and proper release handlingextensions/mattermost/src/channel.tsto passallowPrivateNetworkinto probe callsextensions/mattermost/src/mattermost/probe.test.tsto mock the guard directly and cover policy forwardingUnreleasedfix note toCHANGELOG.mdValidation
pnpm test -- extensions/mattermost/src/mattermost/probe.test.tspnpm test -- extensions/mattermost/src/channel.test.tspnpm checkafter rebasing onto latestorigin/main; it still fails on unrelated pre-existing TypeScript issues inextensions/openai,extensions/openrouter, andsrc/agents/skills*fetch()and now routes throughfetchWithSsrFGuardclaude -p "/review"; it did not review the workspace diff and instead prompted for an open PR number, so I relied on the focused local tests aboveNotes
pnpm checkis not green on latestorigin/mainbecause of the unrelated TypeScript issues listed above