Extract shared parseJsonObjectFromText and getConnectionFingerprint utilities#2472
Draft
Copilot wants to merge 2 commits into
Draft
Extract shared parseJsonObjectFromText and getConnectionFingerprint utilities#2472Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
…tilities Deduplicate the triplicated JSON parser from useRowSummaries, useNamespaceSummaries, and usePageSlotInsights into a shared parseJsonObjectFromText utility. Centralize getConnectionFingerprint with hashed output (DJB2a) to avoid leaking raw credentials in React Query keys. Previously useServiceDashboardQueries used raw joined fields while useInstrumentationScore used hashed output. Add focused unit tests for both utilities. Co-authored-by: strawgate <[email protected]>
Copilot
AI
changed the title
[WIP] [code-duplication] Remove duplicate JSON parser from hooks
Extract shared parseJsonObjectFromText and getConnectionFingerprint utilities
Mar 15, 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.
Three LLM hooks had identical copy-pasted
parseJsonObjectFromTextimplementations, and two hooks had divergentgetConnectionFingerprint— one hashed, one returning raw credentials in React Query keys.Shared utilities
src/utils/parseJsonObjectFromText.ts— Single source for LLM response JSON extraction (fence stripping, brace slicing,JSON.parse). Replaces locals inuseRowSummaries,useNamespaceSummaries,usePageSlotInsights.src/utils/connectionFingerprint.ts— CanonicalgetConnectionFingerprintusing DJB2a hash. Replaces locals inuseInstrumentationScoreanduseServiceDashboardQueries.Behavior change
useServiceDashboardQueriespreviously put rawapiKey/passwordvalues into query keys. Now uses the hashed fingerprint, consistent withuseInstrumentationScore. Query keys change shape on upgrade — one-time cache miss, no functional impact.Tests
parseJsonObjectFromText(plain, fenced, nested, garbage input)getConnectionFingerprint(null, stability, differentiation, no raw credential leakage)Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.