This repository was archived by the owner on Sep 11, 2025. It is now read-only.
fix: validate inference history is valid json#916
Merged
mattjohnsonpint merged 1 commit intomainfrom Jun 25, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds JSON validation for inference history entries to ensure only valid JSON is stored, adjusts database logging to mark certain errors as user-visible, and documents the change in the changelog.
- Add
gjsonvalidation and error handling ingetInferenceDataJson - Update
logDbWarningOrErrorto include auser_visibleflag on logged errors - Record the fix in
CHANGELOG.md
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| runtime/db/inferencehistory.go | Renamed local variable, added gjson.ValidBytes check, and return error on invalid JSON |
| runtime/db/db.go | Modified logger call to include user_visible metadata |
| CHANGELOG.md | Added entry for v0.18.2 with JSON validation fix |
Comments suppressed due to low confidence (2)
runtime/db/inferencehistory.go:181
- Consider adding unit tests to cover both valid and invalid JSON inputs so the new validation logic is exercised and guarded against regressions.
if !gjson.ValidBytes(result) {
runtime/db/inferencehistory.go:22
- The code uses
fmt.Errorfon line 182 butfmtis not imported; addimport "fmt"to avoid a compilation error.
"github.com/tidwall/gjson"
kevinmingtarja
approved these changes
Jun 25, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #903