Fix server deletion, Ollama analysis, and stale/missing AI analysis state - #56
Open
nilsanmy wants to merge 3 commits into
Open
Fix server deletion, Ollama analysis, and stale/missing AI analysis state#56nilsanmy wants to merge 3 commits into
nilsanmy wants to merge 3 commits into
Conversation
added 3 commits
August 27, 2026 09:32
…eader deleteServer() called fetch() directly, bypassing the shared request() helper, so it never attached the Authorization header. The backend correctly rejected it with 401, but the response was never checked, so the UI showed a false success and left the server undeleted.
generateAnalysis() and generateAnalysisWithSystemPrompt() threw 'AI provider has no API key configured' for any empty apiKey, even for providers like Ollama/LM Studio that are intentionally configured without one. Extracted a shared resolveApiKeyOrThrow() helper that checks providerConfig.requiresApiKey, used by both methods. Also pass Ollama's native format:"json" request field (via a new jsonMode option) when structured output is expected, since relying on prompt text alone let weaker/local models return unparseable output. Includes regression tests for the Ollama empty-key case, unrecognized providers, and the format:"json" request body.
IssueDetailModal reused local state (analysisResult, conversationHistory,
etc.) across different issues since only props changed, not the
component instance - causing one issue's AI analysis to appear on
every other issue. Added key={detailIssueId} to force remount.
Also, analysisResult was never populated from the DB when opening an
issue with a pre-existing analysis, so Full Analysis appeared empty
until regenerated. Added useLatestAnalysisConversation() to load and
restore it from the existing analysisConversations record.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
nilsanmy
marked this pull request as ready for review
August 27, 2026 10:19
nilsanmy
marked this pull request as draft
August 27, 2026 10:29
nilsanmy
marked this pull request as ready for review
August 27, 2026 13:05
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
Three independent bugs found while running Logarr against a local
Ollama instance for AI-powered issue analysis:
the database when reopening an issue
Changes
1. Server deletion silently fails (
apps/frontend/src/lib/api.ts)deleteServer()calledfetch()directly instead of going through theshared
request()helper, so it never attached theAuthorizationheader. The backend correctly rejected the request with 401, but the
response status was never checked, so the UI showed "server deleted"
and removed the row from view even though nothing was deleted from the
database.
Fix: route
deleteServer()throughrequest()like every otherApiClientmethod, restoring the auth header and response validation.2. AI analysis fails for providers that don't require an API key (
apps/backend/src/modules/settings/ai-provider.service.ts)generateAnalysis()andgenerateAnalysisWithSystemPrompt()both threwAI provider has no API key configuredwhenever the storedapiKeywas empty — even for providers like Ollama and LM Studio that are
intentionally configured with an empty key since they don't need one.
This made AI analysis unusable for any local/self-hosted provider.
Fix: extracted a shared
resolveApiKeyOrThrow()helper that onlythrows when
providerConfig.requiresApiKeyis true, used by bothmethods so the check can't drift out of sync again (the previous
duplicated logic was fixed in one method but missed in the other).
Also fails closed with a clear error if
setting.providerdoesn'tmatch a known provider, instead of silently treating it as key-optional.
3. Ollama analysis output frequently fails to parse
Even with 2 fixed, structured analysis from Ollama often failed with
"The AI analysis could not be parsed as structured data" — the app
only asked for JSON via the system prompt, with no structural
guarantee the model would comply. Weaker/local models often prepended
text, used unclosed markdown fences, or produced near-valid JSON.
Fix: added a
jsonModeoption toAiGenerationOptionsand passOllama's native
format: "json"request field when set (enabled forgenerateAnalysisWithSystemPrompt(), since that's the method whosecallers always expect structured JSON back). This constrains Ollama's
token sampling to valid JSON rather than relying on instruction
following alone.
4. Stale/missing AI analysis in the issue detail modal (
apps/frontend/src/app/(dashboard)/issues/page.tsx,apps/frontend/src/hooks/use-api.ts)Two related bugs in
IssueDetailModal:reused across different issues (only the
issueIdprop changes), solocal state (
analysisResult,conversationHistory, etc.) persistedfrom whichever issue was last viewed, making one issue's analysis
appear on every subsequently opened issue.
analysisResultwas only everpopulated by generating a new analysis in the current session.
Opening an issue that already had a stored analysis (visible on the
Overview tab via
issue.aiAnalysis) showed an empty Full Analysistab until you regenerated it — even though the backend already had a
working endpoint for this (
GET /issues/:id/analyze/conversation).Fix:
key={detailIssueId}to force a full remount on issue change,resetting all local state at once.
useLatestAnalysisConversation()query hook and auseEffectthat restores
analysisResult/conversationHistoryfrom the storedanalysisConversationsrecord when one exists and nothing's beengenerated yet in the current session.
Known limitation
Restored analyses show
0for the context summary counts(occurrences/users/sessions included) since these aren't persisted on
the
analysisConversationsrecord — only available for a freshlygenerated analysis in the current session. A follow-up could persist
contextSnapshotcounts to fix this fully.