fix: use dash separators in JSON filename and fix const-binding mutation#118
Open
SoundMatt wants to merge 1 commit into
Open
fix: use dash separators in JSON filename and fix const-binding mutation#118SoundMatt wants to merge 1 commit into
SoundMatt wants to merge 1 commit into
Conversation
…binding Two issues in json_writer.cpp: (a) getFormattedTimestampNow was called with format '%H:%M:%S', embedding colons in the filename which are illegal on Windows and cause problems in URLs and shells — change to '%H-%M-%S'. (b) handleAIReasonerInferenceResults iterated with 'const auto &[schema, section]' then wrote to section["..."], which mutates through a const reference (undefined behaviour) — change the binding to 'auto &'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
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.
Problem
Two bugs in
json_writer.cpp: (a)storeJsonToFilecallsgetFormattedTimestampNow("%H:%M:%S", ...)to build the filename, embedding colon characters that are illegal in filenames on Windows and cause problems in URLs and shells. (b)handleAIReasonerInferenceResultsiterates withconst auto &[schema, section]and then writessection["AI.Reasoner.InferenceResults"] = ..., mutating through a const reference, which is undefined behaviour.Root cause
(a) The
%H:%M:%Sstrftime format produces colons that are valid in timestamps but not in filenames. (b) The structured binding was declaredconstbut the loop body modifies the boundsection, which nlohmann/json'sitems()returns as a reference to the underlying JSON value.Fix
(a) Change the format string to
"%H-%M-%S"so the filename uses dashes. (b) Changeconst auto &[schema, section]toauto &[schema, section]so the mutation is through a non-const reference.