Skip to content

fix(gateway): fix semantic search invoke.py response parsing - #1953

Merged
EashanKaushik merged 1 commit into
awslabs:mainfrom
jyotsnamas:fix/semantic-search-response-parsing
Aug 24, 2026
Merged

fix(gateway): fix semantic search invoke.py response parsing#1953
EashanKaushik merged 1 commit into
awslabs:mainfrom
jyotsnamas:fix/semantic-search-response-parsing

Conversation

@jyotsnamas

Copy link
Copy Markdown
Contributor

Summary

  • scripts/semantic-search/invoke.py parses the wrong response path for the x_amz_bedrock_agentcore_search tool
  • Before: result.get("result", {}).get("structuredContent", {}).get("tools", []) — always returns []
  • After: json.loads(result.get("result", {}).get("content", [])[0]["text"]).get("tools", []) — returns actual results
  • Also adds missing import json

Root cause

The semantic search tool returns results as a JSON string inside result.content[0].text, not in result.structuredContent. The script silently returned empty tool lists.

Test plan

  • Verified against live gateway with 318 tools — search for "credit research tools" returns 3 relevant matches
  • Verified search for "restaurant reservation" and "multiplying two numbers" also return correct results
  • Confirmed response format: {"result": {"content": [{"type": "text", "text": "{\"tools\": [...]}"}]}}

🤖 Generated with Claude Code

The semantic search tool returns results in `result.content[0].text`
(JSON string containing a tools array), not in `result.structuredContent.tools`.
The old parsing path silently returned empty results.

Also adds missing `import json` needed for `json.loads()`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Latest scan for commit: 47b04b0 | Updated: 2026-08-13 20:18:52 UTC

Security Scan Results

Scan Metadata

  • Project: ASH
  • Scan executed: 2026-08-13T20:18:38+00:00
  • ASH version: 3.0.0

Summary

Scanner Results

The table below shows findings by scanner, with status based on severity thresholds and dependencies:

Column Explanations:

Severity Levels (S/C/H/M/L/I):

  • Suppressed (S): Security findings that have been explicitly suppressed/ignored and don't affect the scanner's pass/fail status
  • Critical (C): The most severe security vulnerabilities requiring immediate remediation (e.g., SQL injection, remote code execution)
  • High (H): Serious security vulnerabilities that should be addressed promptly (e.g., authentication bypasses, privilege escalation)
  • Medium (M): Moderate security risks that should be addressed in normal development cycles (e.g., weak encryption, input validation issues)
  • Low (L): Minor security concerns with limited impact (e.g., information disclosure, weak recommendations)
  • Info (I): Informational findings for awareness with minimal security risk (e.g., code quality suggestions, best practice recommendations)

Other Columns:

  • Time: Duration taken by each scanner to complete its analysis
  • Action: Total number of actionable findings at or above the configured severity threshold that require attention

Scanner Results:

  • PASSED: Scanner found no security issues at or above the configured severity threshold - code is clean for this scanner
  • FAILED: Scanner found security vulnerabilities at or above the threshold that require attention and remediation
  • MISSING: Scanner could not run because required dependencies/tools are not installed or available
  • SKIPPED: Scanner was intentionally disabled or excluded from this scan
  • ERROR: Scanner encountered an execution error and could not complete successfully

Severity Thresholds (Thresh Column):

  • CRITICAL: Only Critical severity findings cause scanner to fail
  • HIGH: High and Critical severity findings cause scanner to fail
  • MEDIUM (MED): Medium, High, and Critical severity findings cause scanner to fail
  • LOW: Low, Medium, High, and Critical severity findings cause scanner to fail
  • ALL: Any finding of any severity level causes scanner to fail

Threshold Source: Values in parentheses indicate where the threshold is configured:

  • (g) = global: Set in the global_settings section of ASH configuration
  • (c) = config: Set in the individual scanner configuration section
  • (s) = scanner: Default threshold built into the scanner itself

Statistics calculation:

  • All statistics are calculated from the final aggregated SARIF report
  • Suppressed findings are counted separately and do not contribute to actionable findings
  • Scanner status is determined by comparing actionable findings to the threshold
Scanner S C H M L I Time Action Result Thresh
bandit 0 0 0 0 0 0 387ms 0 PASSED MED (g)
cdk-nag 0 0 0 0 0 0 5.7s 0 PASSED MED (g)
cfn-nag 0 0 0 0 0 0 8ms 0 PASSED MED (g)
checkov 0 0 0 0 0 0 4.7s 0 PASSED MED (g)
detect-secrets 0 0 0 0 0 0 981ms 0 PASSED MED (g)
grype 0 0 0 0 0 0 56.4s 0 PASSED MED (g)
npm-audit 0 0 0 0 0 0 271ms 0 PASSED MED (g)
opengrep 0 0 0 0 0 0 <1ms 0 SKIPPED MED (g)
semgrep 0 0 0 0 0 0 <1ms 0 MISSING MED (g)
syft 0 0 0 0 0 0 2.3s 0 PASSED MED (g)

@EashanKaushik
EashanKaushik merged commit 86b4cae into awslabs:main Aug 24, 2026
7 checks passed
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.

2 participants