refactor(resource): ensure post-fetch hooks receive resolved gateway content#2655
Conversation
d78dfd9 to
5eb1aa2
Compare
|
Good fix, @TS0713 — post-fetch hooks should definitely receive resolved content, not template URIs. The refactored control flow with a single return path and null checks on Two things to address: 1. Removed 2. Unrelated files from incorrect rebase: git checkout origin/main -- plugins/unified_pdp/ tests/unit/plugins/test_unified_pdp.py tests/unit/plugins/test_unified_pdp_plugin.py
git commit -s -m "chore: remove unrelated files from rebase" |
Thanks for flagging this — read_resource was holding the DB transaction until invoke_resource. I’ll add an explicit commit immediately before gateway invocation so connections aren’t held across plugin or network calls, then rebase, re-test, and update the PR. |
…content Move RESOURCE_POST_FETCH hook invocation to after invoke_resource() resolves content from the gateway. Previously, post-fetch plugins (e.g. secrets_detection) received raw template URIs instead of actual content, allowing secrets to pass through unredacted. Also adds null-checks before setting blob/text from invoke_resource() response, and normalizes the content resolution into a single if/elif/else chain with one return point. Closes #2648 Signed-off-by: Satya <tsp.0713@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
79495e0 to
fd76484
Compare
Review & Rebase SummaryRebased onto Changes made during rebase
Review notesLogic — Correct. Moves Consistency — Matches the existing Security — This is a security improvement: closes a gap where resolved secrets could bypass plugin redaction. Performance — No impact; hook invocation is moved, not duplicated. Tests — All 21 related tests pass. Full unit suite passes (1 pre-existing flaky cache timing test unrelated to this PR). Structural improvements in the PR:
|
…content (IBM#2655) Move RESOURCE_POST_FETCH hook invocation to after invoke_resource() resolves content from the gateway. Previously, post-fetch plugins (e.g. secrets_detection) received raw template URIs instead of actual content, allowing secrets to pass through unredacted. Also adds null-checks before setting blob/text from invoke_resource() response, and normalizes the content resolution into a single if/elif/else chain with one return point. Closes IBM#2648 Signed-off-by: Satya <tsp.0713@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Summary
Fixes Issue 2648 by invoking resources before running post-fetch hooks.
Changes
mcp-context-forge/tests/unit/plugins/test_secrets_detection.py