fix(web-app-ai-sensitive-data-scanner): render scan findings instead of raw json - #533
Merged
Merged
Conversation
…of raw json Signed-off-by: Lukas Hirt <info@hirt.cz>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
mzner
approved these changes
Jul 27, 2026
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
response_format: { type: 'json_object' }, but in practice the model frequently wraps its JSON response in a markdown code fence (```json ... ```) anyway.parseLlmResponseinuseScanner.tscalledJSON.parsedirectly on the raw content, so the fenced response failed to parse and the entire fenced blob (including the```fences) fell through to thenarrativefallback, which the component renders verbatim as preformatted text — producing the "raw JSON dumped in a code fence" bug shown in the issue screenshot.parseLlmResponseto:```json ... ```or bare``` ... ```) before attempting to parse.{and the last}(handles cases where the model adds leading/trailing prose around the JSON object).narrativeif none of the above yield a valid{ findings: [...] }payload — preserving the existing plain-text fallback behavior for genuinely non-JSON responses.ScanResultsModal.vue's existing findings-list rendering (icon + category label + excerpt) was already correct; the bug was purely in parsing.Test plan
packages/web-app-ai-sensitive-data-scanner/tests/unit/composables/useScanner.spec.tscovering: plain JSON,```jsonfenced JSON, bare```fenced JSON, JSON with surrounding prose, and genuine non-JSON prose (narrative fallback).pnpm --filter web-app-ai-sensitive-data-scanner test:unit— all tests pass (24/24, including existingScanResultModal.spec.ts).pnpm --filter web-app-ai-sensitive-data-scanner check:types— passes.pnpm --filter web-app-ai-sensitive-data-scanner lint— passes.Closes #531
🤖 Generated with Claude Code