Skip to content

Conversation

@LBaronceli
Copy link

##Description
Fixes [ISSUE #26023 ]
The log stream reader in ApplicationsService blindly parses JSON chunks and accesses .result. If a malformed packet (e.g., undefined or null result) arrives—which can happen during backend race conditions when merging streams from multiple replicas—the UI crashes with a TypeError.
This PR adds a defensive check to ensuring the parsed result is valid before passing it to the UI component.

##Changes

  • Updated getContainerLogs in applications-service.ts to include a try...catch block around JSON parsing.
  • Added a filter to discard null or undefined entries before they reach the subscriber.
  • Added console.error logging for parsing failures to aid in future debugging.

##Verification

  1. Simulated the issue by injecting random undefined packets into the log stream.
  2. Verified that the UI no longer crashes and continues to stream valid logs.

##Steps I used to re-create the issue:

  1. Created multiple replicas.
  2. Made them produce logs continually with:
kubectl patch deployment guestbook-ui -n default --type='strategic' -p '{"spec":{"replicas":5,"template":{"spec":{"containers":[{"name":"guestbook-ui","command":["/bin/sh","-c"],"args":["echo \"Starting log generator...\"; while true; do echo \"$(date -Iseconds) - Log entry from $(hostname) - Random: $RANDOM\"; done"]}]}}}}'
  1. Changed the entries code in ui/src/app/shared/services/applications-service.ts ~ line 321 to add random errors:
const entries = requests.loadEventSource(`/applications/${applicationName}/logs?${search.toString()}`).pipe(
            map(data => {
                // Randomly inject a bad packet to reproduce Issue
                if (Math.random() < 0.05) {
                    console.log('Simulating malformed backend response (Issue #26023 reproduction)...');
                    return undefined as unknown as models.LogEntry;
                }
                return JSON.parse(data).result as models.LogEntry;
            })
        );

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Title of the PR
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

Ensures the log stream handles undefined or invalid JSON payloads
gracefully by filtering them out before they reach the UI state.
Relates to argoproj#26023

Signed-off-by: Luis Baronceli <[email protected]>
@LBaronceli LBaronceli requested a review from a team as a code owner February 2, 2026 23:51
@bunnyshell
Copy link

bunnyshell bot commented Feb 2, 2026

✅ Preview Environment deployed on Bunnyshell

Component Endpoints
argocd https://argocd-rlbf7p.bunnyenv.com/
argocd-ttyd https://argocd-web-cli-rlbf7p.bunnyenv.com/

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔴 /bns:stop to stop the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant