fix: render gateway/tool/prompt/resource audit rows correctly in activity feed - #6351
Open
msureshkumar88 wants to merge 1 commit into
Open
fix: render gateway/tool/prompt/resource audit rows correctly in activity feed#6351msureshkumar88 wants to merge 1 commit into
msureshkumar88 wants to merge 1 commit into
Conversation
…vity feed
_audit_to_activity mapped only two resource_type values that no writer
actually emits (mcp_server, a2a_agent) and only bare verbs, so every
gateway/tool/prompt/resource/server audit row fell through to a
mangled fallback ("Gateway set gateway state") and the health-check
reachability transition rendered as an indistinguishable "success".
Resolve labels against what services actually write, resolve composite
actions (create_gateway, set_tool_state, bulk_create_tools, ...) via a
token scan instead of literal matching, and render set_*_state rows
from their recorded new_values so a server going offline renders as a
warning instead of success. Same fix applied to the error branch,
which had the identical mangling bug on failed writes.
Closes #6342
Signed-off-by: Suresh Kumar Moharajan <suresh.kumar.m@ibm.com>
msureshkumar88
requested review from
Lang-Akshay,
brian-hussey,
crivetimihai and
ja8zyjits
as code owners
August 21, 2026 10:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_audit_to_activity(the renderer behindGET /api/logs/activity) only mapped tworesource_typevalues (mcp_server,a2a_agent) that no writer in the codebase actually emits, and only mapped bare verbs (create,update, ...). Every real gateway/tool/prompt/resource/server audit row therefore fell through to the fallback and rendered mangled titles like "Gateway set gateway state", and the health-check reachability transition was indistinguishable from a normal successful write (status: "success").gateway_service.py/tool_service.py/prompt_service.py/resource_service.py/server_service.pyactually write (gateway→ "MCP server",server→ "Virtual server", etc.), keeping the two existing keys as inert compat entries.create_gateway,set_tool_state,bulk_create_tools,view_prompt_details, ...) via a token scan rather than literal string matching, so a trailing resource noun is discarded instead of repeated.set_*_staterows from their recordednew_values(enabled/reachable) instead of the literal action string, so a server going offline renders asstatus: "warning"/ "MCP server went offline" instead ofsuccess.create_gatewayrendered "MCP server create gateway failed").context.description(used by a fewlog_auditcall sites) over the synthesised sentence when present.Two changes go slightly beyond the issue's literal scope, called out here since they're the same defect class on adjacent code the issue didn't mention:
view_*/browse/invokeactions now resolve tostatus: "info"likeread/executealready did, since status is now derived from the resolved verb rather than a literal string match.Deliberately not changing any writer in
gateway_service.py(the issue's suggested fix #1, flippingsuccess=Falseon the offline transition):AuditTrail.successalso drives SIEM export severity (_emit_audit_event_to_siem) and compliance evidence counts (collect_audit_log_evidence), so writingsuccess=Falsefor a health-check-driven reachability change would export every upstream outage as aseverity: "HIGH"/action_taken: "denied"SIEM event and inflatefailure_eventsin compliance reports, even though the audited write itself succeeded. Deriving status fromnew_valuesin the renderer gets the desired feed behavior without corrupting either downstream consumer.Closes #6342
Test plan
tests/unit/mcpgateway/routers/test_log_search_activity.py— extendedTestAuditMapper, addedTestStateTransitionsand a hardcoded-inventory regression guard (TestRealActionInventoryRegressionGuard) covering every(resource_type, action)pair actually written by the services abovemake ruff bandit interrogate pylinton changed filespytest tests/unit/mcpgateway/routers/(full directory) + targeted audit/compliance service tests